[FFmpeg-user] extract all key frames from a video

tank pranav akshar_tank at yahoo.com
Thu Sep 8 09:30:17 CEST 2011

This is pranav, I am using ffmpeg for video ts file to image conversion by giving following command.

ffmpeg -i video_file.ts destination_directory/img_%05d.jpeg

it generates images in to  destination_directory. But it generates some gray color frames in very begining part. and those number of gray color images is generated in every video ts files. number does not remain fixed , in some ts files those gray color images are 70 to 80, in some other video file it remains 2000-5000. 

When I open that video ts file in to dvbcut then dvbcut only shows actual frames. Then I could not correlate what ffmpeg does and what dvbcut shows. In documentation of dvbcut says they are using ffmpeg as internal library then why such thing should have happened ???

My conclusion :- 
I think so, ffmpeg does not find where from 1st I frame starts .......

If it gives initial gray color frame then it definately means that it did not find I-frame thati s why ffmpeg keeps on inserting dummy frames.

We need to change something in ffmpeg's coding. Where should we change that I am still figuring out. If you have any idea how we should keep on drop the frame till we get I frame then it may solve my purpose.

I dont know I am right or wrong, if u can help me out with this issue then it would be great.

From: lovelove <googol at wolke7.net>
To: ffmpeg-user at ffmpeg.org
Sent: Wednesday, September 7, 2011 9:04 PM
Subject: Re: [FFmpeg-user] extract all key frames from a video

Stefano Sabatini wrote:
> On date Wednesday 2011-09-07 02:01:51 -0700, lovelove encoded:
>> Hi. I tried to use the new key-frame filter (
>> http://ffmpeg.org/trac/ffmpeg/ticket/92 Ticket #92 ) [...]
>> My command is:
>> *ffmpeg.exe -i inputfile.avi -vf select="eq(pict_type\,PICT_TYPE_I)" -s
>> 400x300 -f image2 outputfile.AVI-%03d.tif*
>> [...]
>> yes, the output images are key frames. But way too much. After 3
>> seconds, I already had 378 output images, of which only 3 were unique
>> (the
>> rest were duplicates).  
> -vsync 0 (-vsync -1 is the default)

That works, thank you so much!

I read up on the -vsync param. It says:
0 = Each frame is passed with its timestamp from the demuxer to the muxer
2 = Frames are passed through with their timestamp or dropped so as to
prevent 2 frames from having the same timestamp.

I tried both 0 and 2 in the quoted ffmpeg above and both seem to generate
the same output in this case. Do they really do the same in my case, or does
one of them have any advantage/disadvantage for me which I'm missing? Should
0 or 2 in theory be faster? In my tests there was no speed (performance)

Other issue: the output images are fine, however the console text output
mysteriously repeats again so many lines (just as I posted earlier on
today). Any idea why?

View this message in context: http://ffmpeg-users.933282.n4.nabble.com/extract-all-key-frames-from-a-video-tp3795626p3796429.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.
ffmpeg-user mailing list
ffmpeg-user at ffmpeg.org

More information about the ffmpeg-user mailing list