Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use ffmpeg to cut video files at precise times. The ffmpeg help shows an option -timecode_frame_start to specify the starting frame but I am unable to get this command to work. The resulting video always starts at the beginning of the original video. Here's an example of the command I'm running:

ffmpeg -i input.mpg -acodec copy -vcodec copy -timecode_frame_start 200 -vframes 210 -n ouput.mpg

I've moved the timecode_frame_start option before and after the other options with no change in results. Is there an additional option I need to specify? I've tried various file formats, mkv, avi, mp4, and it doesn't appear the problem is codec related. Here is one file I've tried:

Am I missing something?

share|improve this question
appears this was answered on the mailing list (and NB that with -vcodec copy you can't "really" get frame specific cutting, since it can only resynchronize on i-frames – rogerdpack Aug 9 '12 at 11:46
@user39364 I asked on the mailing list and it turns out that this option doesn't do what the OP wants. I also learned something new :) – slhck Aug 9 '12 at 11:46
up vote 26 down vote accepted

I just learned that the timecode_frame_start does not work like this. The only way to start at specific frames is to convert a number of frames to syntax, or So, if your video is at 25 fps, and you want to start at 133 frames, you would need

133 / 25 = 5.32

So, run

ffmpeg -ss 5.32 -i input.mp4 -c:v libx264 -c:a libfaac out.mp4

Note that cutting on exact frames with bitstream copy (-c:v copy) is not possible since not all frames are intra-coded and can stand on their own.

If you are using a recent version of ffmpeg (> 2.1), transcoding (that is, using anything but -c:v copy), -ss will always be frame-accurate.

You also have the choice to use video filters but audio support might not be exact. And apparently, seeking on frames is still not a feature. You can follow this FFmpeg-users mailing list thread for more info:

you may use -vf select for accurate frame selection (something like -vf 'select=gte(n\,100)' to skip the 100 first frames)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .