Skip to content

Instantly share code, notes, and snippets.

@ClimenteA
Created May 27, 2023 07:29
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 ClimenteA/ea70c3f6592a4377f8880b9a0c7b8be7 to your computer and use it in GitHub Desktop.
Save ClimenteA/ea70c3f6592a4377f8880b9a0c7b8be7 to your computer and use it in GitHub Desktop.
FFmpeg + Python split big video in 30 minutes chunks
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