[FFmpeg-user] Cutting video at i-frames to avoid recoding

Stefano Sabatini stefasab at gmail.com
Sat Aug 18 23:43:06 CEST 2012


On date Saturday 2012-08-18 17:30:21 -0400, Andy Civil encoded:
> Hi
> 
> Context: I have some home movies of animals doing cute things, where
> I left the camera running so a good portion is garbage. I want to
> cut out and keep the good parts, but I don't want to re-encode
> because then it wouldn't feel like the 'original' footage, as it
> were. I know that you can't cut a H.264 movie just anywhere, because
> the output file has to start with an i-frame.
> 
> I know that FFmpeg can "-vcodec copy" and I know that you can also
> set "-ss" start time and duration; but I don't know if you can do
> both at once, and if you can, how does it behave? (I'm thinking that
> the GOP could be as many as 300 frames, and I believe FFmpeg 'only
> goes forwards' so it is not reasonable to think that you could
> specify a start time and expect it to go BACK in the stream to the
> previous i-frame; that's just not how it works, right?)
> 
> So my basic question is: how can I cut a h.264 movie without
> recoding anything, specifying a start and stop time?
> 
> It would be perfectly acceptable if the first frames were simply
> grey, containing only the differences - I know this is possible
> because sometimes on youtube, you see videos that have been cut this
> way; here's an example:
> http://www.youtube.com/watch?v=SwRFoxgEcHc
> (watch just the first few seconds "are about to perform" before an
> i-frame comes along and clears things up).

I don't think skipping I-frames is a good idea if you want a decent
footage quality (much better to re-code the file in that case).

You may have a look at the segment muxer, it may be useful depending
on what you want to exactly achieve.
-- 
ffmpeg-user random tip #22
See the capture of a video4linux device:
ffplay -s 640x480 -f video4linux /dev/video0 


More information about the ffmpeg-user mailing list