Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Handy tip for trimming demo videos

Handy tip for trimming demo videos

Thought I'd document the process I used for trimming down my React conf demo videos in case it might be useful to someone else in the future.

Let's say I have a 40 second video named original-video.mp4, and I want to only keep the following sections (in seconds): 1-8, 10-11, 20-33

I could create 3 chunks using ffmpeg like so:

ffmpeg -i original-video.mp4 -ss 1 -t 7 piece-a.mp4 -ss 10 -t 1 piece-b.mp4 -ss 20 -t 33 piece-c.mp4

Then write the names of these pieces to a text file:

cat >> video-pieces.txt << EOF
file 'piece-a.mp4'
file 'piece-b.mp4'
file 'piece-c.mp4'
EOF

Then lastly, use ffmpeg to stitch them back together into a single file:

ffmpeg -f concat -i video-pieces.txt -c copy trimmed-video.mp4

I know other tools (like QuickTime) let you trim, but I don't know if they let you splice sections out. (I'm not a QuickTime power user.) The above is pretty easy and fast though so...hope it helps someone!

@bvaughn

This comment has been minimized.

Copy link
Owner Author

@bvaughn bvaughn commented Oct 23, 2019

There's probably a way to skip the text file step and just feed ffmpeg the file names directly. The documentation shows using an intermediate file though so 🤷‍♂️

@fbartho

This comment has been minimized.

Copy link

@fbartho fbartho commented Oct 23, 2019

This is super neat! Having simple command line recipes like this is awesome, thanks for sharing!

If you do want to know how to replicate this inside QuickTime, I’ve done similar things with the split & trim tools. (It has been a while!) https://support.apple.com/en-us/HT201066#edit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment