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 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:

http://www.seaotter.com/marine/movies/hermit-long-01.mpg

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
add comment

1 Answer

up vote 12 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 hh:mm:ss.ms. So, if your video is at 25 fps, and you want to start at 133 frames, you would need to calculate:

133 / 25 = 5 s and 8 frames (since .32 × 25 = 8 frames
1000 ms / 25 fps = 40 ms per frame
8 frames × 40 ms per frame = 320 ms
Resulting timecode: 00:00:05.320

I made this an Excel sheet you can download here. Use the timecode like this:

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

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

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.

share|improve this answer
1  
Thanks, I was looking for the dot notation for the milliseconds. I had tried a colon and a comma originally. I figured it out not long after posting but I was hoping there was a way to get the frame start to work too. Thanks a lot for the explanation and additional details. –  curmil Aug 9 '12 at 22:32
add comment

Your Answer

 
discard

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.