Some Useful ffmpeg Incantations

ffmpeg, if you haven’t heard of it, is a free, open source video multitool. I use it for many different things, but just infrequently enough to forget the commands. Thought I’d write a few of them here.

Here’s how to cut a section from a full video, without re-encoding the video. This command crops the first ten seconds and copies that content to a new file:

ffmpeg -i video_full.mp4 -ss 00:00:00 -to 00:10:00 -c copy video_section.mp4

To concatenate multiple clips without re-encoding, you need to create a list. You can type this list in the command window but it’s easier to create a text file with the following format.

file '/path/to/clip1'
file '/path/to/clip2'
file '/path/to/clip3'

Then

ffmpeg -f concat -safe 0 -i vidlist.txt -c copy output

Although it may seem a bit clunky, this is a fast way to trim out unwanted sections of clips without re-encoding. Simply trim out the good section and then concatenate them together.

(I got this example from Elder Geek on Stackoverflow)

Here’s how to convert a video into a sequence of still images:

ffmpeg -i video.flv image%d.jpg

And back:

$ ffmpeg -f image01 -i image%d.jpg video.mp4
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Some Useful ffmpeg Incantations

Leave a Reply

Your email address will not be published. Required fields are marked *