Created
July 10, 2016 22:02
-
-
Save lopezpdvn/dea4a3301a58335525a9aea7aa1cdb4e to your computer and use it in GitHub Desktop.
ffmpeg trim/cut video to video
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
from datetime import timedelta | |
from subprocess import Popen | |
'''ffmpeg_trim_cut_video2video.py | |
Edit section *User data*, and uncomment one of the commands `cmd` | |
''' | |
# User data | |
tstart = timedelta(minutes=18, seconds=20, milliseconds=0) | |
tend = timedelta(minutes=18, seconds=30, milliseconds=0) | |
src = 'video_src.mkv' | |
output = 'output.mkv' | |
ffmpeg = 'ffmpeg' | |
tdelta = tend - tstart | |
tstart = str(tstart) | |
tend = str(tend) | |
tdelta = str(tdelta.total_seconds()) | |
cmd = (ffmpeg, '-i', src, '-ss', tstart, '-c:v', 'copy', '-c:a', 'copy', '-to', | |
tend, output) | |
#cmd = (ffmpeg, '-ss', tstart, '-i', src, '-c:v', 'copy', '-c:a', 'copy', '-t', | |
# tdelta, output) | |
#cmd = (ffmpeg, '-ss', tstart, '-i', src, '-t', tdelta, output) | |
#cmd = (ffmpeg, '-i', src, '-ss', tstart, '-to', tend, output) | |
proc = Popen(cmd) | |
print('Exit code: {}'.format(proc.wait())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment