Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having trouble finding a cli application that can take a video file (avi, mkv, and mp4 preferably) and cut out very short clips (2-6 seconds) with precision time accuracy. I've tried ffmpeg, mencoder, avidemux, and mp4box but they all cut on keyframes which creates 6+ second clips. Is there a tool that will re-encode the input file and cut the accurate time or cut inaccurately, re-encode, and then cut accurately?

share|improve this question
You'll probably have to reencode before cutting to get it right. You could probably speed things up by first cutting out the surrounding keyframes and only reencode the snippets. –  Nifle Aug 7 '12 at 18:19
Which FFmpeg command have you tried, exactly? I believe if you decode the video before (i.e. place the -ss parameter after -i), it should be more accurate. –  slhck Aug 7 '12 at 18:19
The FFmpeg trick worked! I didn't realize the order mattered so much. Is this the same for any of the other tools? –  curmil Aug 7 '12 at 19:30

1 Answer 1

up vote 8 down vote accepted

You can accurately cut videos with FFmpeg. Note that the order of input options is important.

This would for example cut 5 seconds, starting from 5 minutes, 3 seconds and 123 milliseconds.

ffmpeg -i input.mp4 -ss 00:05:03.123 -t 5 -c:v libx264 -c:a libfaac out.mp4

Read the input options from left to right: First the input will be decoded, then it will start encoding, and it'll output video at the time specified by -ss. This means cutting will always take as long as encoding the whole file though.

This, however, will not work accurately:

ffmpeg -ss 00:05:03.123 -i input.mp4 …

FFmpeg will try to estimate the starting position without actually decoding the video, which will always be inaccurate. See also:

-ss position (input/output)

When used as an input option (before -i), seeks in this input file to position. When used as an output option (before an output filename), decodes but discards input until the timestamps reach position. This is slower, but more accurate.

position may be either in seconds or in hh:mm:ss[.xxx] form.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.