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

1 Answer 1

up vote 15 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 ss.ms syntax, or hh:mm:ss.ms. 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 -i input.mp4 -ss 5.32 -c:v libx264 -c:a libfaac out.mp4

Note that cutting on exact frames with bitstream copy (-c 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
    
whats wrong with just using 133/25 = 5.32 ? you can say -ss 5.32 no need to mess around with hh:mm:ss syntax. if you divide by frame rate you will always get correct number of fractional seconds. no need for spreadsheets. –  unsynchronized May 31 at 3:03
    
@unsynchronized You're right. Last time I had checked the documentation there was no mention of being able to use fractional seconds (just integers). I updated the post. –  slhck May 31 at 7:18

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.