Last active
February 22, 2018 17:15
-
-
Save previtus/034a4946717ef2452612a7f2a72b512c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# thanks to https://github.com/bapoczos/ArtML/blob/master/fast-style-transfer/transform_video.py | |
# thanks to Barnabas Poczos and Gene Kogan | |
import subprocess, shutil | |
import os, fnmatch | |
in_args = [ | |
'ffmpeg', | |
'-i', in_path, | |
'%s/frame_%%d.png' % in_dir | |
] | |
subprocess.call(" ".join(in_args), shell=True) | |
files = sorted(os.listdir(in_dir)) | |
base_names = fnmatch.filter(files, '*.png') | |
in_files = [os.path.join(in_dir, x) for x in base_names] | |
out_files = [os.path.join(out_dir, x) for x in base_names] | |
evaluate( ... ) | |
fr = 30 | |
out_args = [ | |
'ffmpeg', | |
'-i', '%s/frame_%%d.png' % out_dir, | |
'-f', 'mp4', | |
'-q:v', '0', | |
'-vcodec', 'mpeg4', | |
'-r', str(fr), | |
out | |
] | |
subprocess.call(" ".join(out_args), shell=True) | |
print('Video at: %s' % out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment