import shutil import os from subprocess import call from app.settings import app_cfg def export_video(fp_frames, fps=30): print("Exporting video...") cmd = [ '/usr/bin/ffmpeg', '-hide_banner', '-y', # '-v', 'quiet', '-r', str(fps), '-i', os.path.join(app_cfg.DIR_OUTPUTS, fp_frames, 'frame_%04d.png'), '-pix_fmt', 'yuv420p', os.path.join(app_cfg.DIR_OUTPUTS, fp_frames + '.mp4') ] # print(' '.join(cmd)) call(cmd) shutil.rmtree(os.path.join(app_cfg.DIR_OUTPUTS, fp_frames)) def export_video_final(fp_frames, fp_out, fps=25): if os.path.exists(fp_out): print("Video already exists: {}".format(fp_out)) return None print("Exporting video...") cmd = [ '/usr/bin/ffmpeg', '-hide_banner', '-y', # '-v', 'quiet', '-r', str(fps), '-i', os.path.join(app_cfg.DIR_OUTPUTS, fp_frames, 'frame_%05d.png'), '-c:v', 'libx264', '-preset', 'slow', '-crf', '19', '-vf', 'fps=25', '-pix_fmt', 'yuv420p', '-s', '512x512', fp_out ] # print(' '.join(cmd)) call(cmd) return fp_out