Skip to content

Instantly share code, notes, and snippets.

@berndverst
Last active April 4, 2020 00:00
Show Gist options
  • Save berndverst/6308d9427e5df935dbe331c135e82502 to your computer and use it in GitHub Desktop.
Save berndverst/6308d9427e5df935dbe331c135e82502 to your computer and use it in GitHub Desktop.
Trimming videos instantly without reencoding using FFmpeg
INFILE="video.mp4"
OUTFILE="shortenedclip.mp4"
START="00:00:12.35" # Start Time in hh:mm:ss.msec format
DURATION="00:01:05.4" # Duration in hh:mm:ss.msec format
################## Alternative format ##################
# START="12.35" # Start time in s.msec format #
# DURATION="65.4" # Duration time in s.msec format #
########################################################
ffmpeg -ss $START -i $INFILE -c copy -map 0 -t $DURATION $OUTFILE
# If you prefer you can also specify an end time similar to the start time
END="00:01:12.75"
ffmpeg -ss $START -i $INFILE -c copy -map 0 -to $END $OUTFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment