Created
August 15, 2020 07:19
-
-
Save NeuroWhAI/b1ec81b9e264c55c4c6d0f2ab4fedfc4 to your computer and use it in GitHub Desktop.
이미지 시퀀스를 ffmpeg로 YouTube용 영상으로 변환하기. (720p)
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
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