Created
June 10, 2023 08:17
-
-
Save ClimenteA/b1a6a803e822e222798d1e7319d1cddc to your computer and use it in GitHub Desktop.
Concat with FFmpeg videos from a folder
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 | |
# Assuming video files are in this format: "1.mp4" | |
filepaths = [f for f in os.listdir() if f.endswith(".mp4")] | |
sorted_filepaths = sorted(filepaths, key=lambda val: int(val.split(".")[0])) | |
allvids = [f'file {os.path.abspath(f)}' for f in sorted_filepaths] | |
with open("vids.txt", "w") as f: | |
f.write("\n".join(allvids)) | |
# cat vids.txt | |
os.system("ffmpeg -f concat -safe 0 -i vids.txt -c copy curs_programare.mp4") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another option: