Created
May 27, 2023 07:29
-
-
Save ClimenteA/ea70c3f6592a4377f8880b9a0c7b8be7 to your computer and use it in GitHub Desktop.
FFmpeg + Python split big video in 30 minutes chunks
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 subprocess | |
def split_video(input_file, output_prefix, duration=1800): | |
command = [ | |
'ffmpeg', | |
'-i', input_file, | |
'-c', 'copy', | |
'-segment_time', str(duration), | |
'-f', 'segment', | |
'-reset_timestamps', '1', | |
'-segment_format', 'mp4', | |
output_prefix + '%03d.mp4' | |
] | |
subprocess.run(command) | |
# Example usage | |
input_file = 'bigvid.mp4' | |
output_prefix = 'vids30mins' | |
split_video(input_file, output_prefix, duration=1800) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment