Skip to content

Instantly share code, notes, and snippets.

@NeuroWhAI
Created August 15, 2020 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeuroWhAI/b1ec81b9e264c55c4c6d0f2ab4fedfc4 to your computer and use it in GitHub Desktop.
Save NeuroWhAI/b1ec81b9e264c55c4c6d0f2ab4fedfc4 to your computer and use it in GitHub Desktop.
이미지 시퀀스를 ffmpeg로 YouTube용 영상으로 변환하기. (720p)
import os
from os import walk
list_file = "img_paths.txt"
for (_, _, filenames) in walk("img"):
with open(list_file, "w") as f:
f.writelines(map(lambda name: f"file img/{name}\n", filenames))
break
imgs_per_second = 12
os.popen(f"ffmpeg -y -r {imgs_per_second} -f concat -safe 0 -i {list_file} "\
"-vf \"yadif,format=yuv420p,scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2\" "\
"-force_key_frames \"expr:gte(t,n_forced/2)\" -use_editlist 0 -movflags +faststart "\
"-preset slow -crf 20 -bf 2 -c:v libx264 -b:v 50M out.mp4").read()
os.remove(list_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment