Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ffmpeg notes

ffmpeg notes

I often want to do something that I believe is non-trivial in ffmpeg, only to discover that it is actually very simple, if only I had known how to do it. I even end up writing wrappers to do simple things, because I keep forgetting what to do. However, this file is my new solution: simply write my own documentation for things I would occasionally like to do.

Trimming video between two timecodes

ffmpeg -ss 1:00 -to 2:00 -i input.mkv -c copy output.mkv
  • -ss 1:00 (before -i): start reading input at time 1:00
  • -to 2:00: stop reading input at time 2:00
  • -c copy use the original encoding

Trimming video to a given duration

ffmpeg -i input.mkv -t 1:00 -c copy output.mkv
  • -t 1:00: limit output duration to one minute

Concatenating (parts of) videos together

First create a file list in concat.txt. Full syntax here.

file 'input1.mkv'
	inpoint 1:00
	outpoint 2:00

file 'input2.mkv'
	inpoint 0:30
	outpoint 1:30

file 'input3.mkv'
file 'input4.mkv'

Consider inpoint and outpoint the same way as -ss and -to above. Now,

ffmpeg -f concat -safe 0 -i concat.txt -c copy output.mkv
  • -safe 0: stop the demuxer from rejecting 'unsafe' file paths. Not always necessary, obviously. See the documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.