jp4-to-png.py 580 Bytes
Newer Older
1 2
#!/usr/bin/env python3

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
3
from jp4_composite import JP4_C
4 5 6 7
#import cv2
import numpy as np
import sys
from PIL import Image, ImageOps
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
8
import os
9 10 11 12 13 14

try:
  filename = sys.argv[1]
except IndexError:
  filename = "test.jp4"

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
15
img = JP4_C(filename)
16
#print(img.exif.toString())
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
17
#print(img.exif.data['Model'])
18 19 20
img.deblock()
img.demosaic_bilinear()
img.saturation()
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
21
subs = img.extract_subframes()
22

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
23 24 25
for i in range(len(subs)):
  #subs[i].save(os.path.join("../res",img.basename+"_"+str(img.subnames[i])+".png"))
  subs[i].save(os.path.join("../res",img.basename+"_"+str(img.subnames[i])+".jpeg"))