I'm trying to convert an html5 video to mp4 video and am doing so by screen shooting through PhantomJS over time
I'm also cropping the images using PIL so eventually my code is roughly:
while time() < end_time:
screenshot_list.append(phantom.get_screenshot_as_base64())
.
.
for screenshot in screenshot_list:
im = Image.open(BytesIO(base64.b64decode(screenshot)))
im = im.crop((left, top, right, bottom))
Right now I'm saving to disc all those images and using ffmpeg from saved files:
os.system('ffmpeg -r {fps} -f image2 -s {width}x{height} -i {screenshots_dir}%04d.png -vf scale={width}:-2 '
'-vcodec libx264 -crf 25 -vb 20M -pix_fmt yuv420p {output}'.format(fps=fps, width=width,
screenshots_dir=screenshots_dir,
height=height, output=output))
But I want instead of using those saved files, to be able to pipe the PIL.Images directy to ffmpeg, how can I do that?