Last active
August 29, 2015 14:03
-
-
Save crowsonkb/1329b0ba25b4547dd4b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import numpy as np | |
import sys | |
FRAME_SIZE = 1920*1080*3 | |
BPC = 2 | |
MAXINT = (256**BPC) - 1 | |
GAMMA = 2.0 # A much faster approximation than 2.2 | |
accum = np.zeros(FRAME_SIZE, dtype='f4') | |
count = 0 | |
while True: | |
data = sys.stdin.read(FRAME_SIZE*BPC) | |
if len(data) < FRAME_SIZE*BPC: | |
break | |
frame = np.fromstring(data, dtype='<u2') | |
accum += (frame.astype('f4')/MAXINT)**GAMMA | |
count += 1 | |
accum /= count | |
accum **= 1/GAMMA | |
accum *= 65535 | |
accum.astype('<u2').tofile(sys.stdout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i BDMV.mov -f rawvideo -sws_flags print_info -vf format=yuv444p -pix_fmt rgb48le - | ./blend.py | ffmpeg -f rawvideo -pixel_format rgb48le -video_size 1920x1080 -i - out.tiff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment