[FFmpeg-user] Extracting I P B frames from a mpg video

Moritz Barsnick barsnick at gmx.net
Mon Jan 5 11:25:36 CET 2015


Hi Rohit,

On Sun, Jan 04, 2015 at 23:46:26 -0800, Rohit wrote:
> ffmpeg -i delta.mpg -vf select="eq(pict_type\,PICT_TYPE_I)" -s 400x300 -f image2 frame.mpg-%03d.tif

You should always show us the complete, uncut output of your command.

> which should extract all the I frames(as per -vf
> select="eq(pict_type\,PICT_TYPE_I)" ) in the input file. But I got 197
> frames instead of 17 from this command and it looked like command has just
> shown me all the frames.

There's a Wiki entry covering this:
https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video

And though it doesn't explain why, it does hint that you need to use:
-vsync vfr

This works for me.

I believe the image2 muxer automatically assumes the same frame rate as
the input (i.e. automatically chooses "-vsync cfr"). Since you are
dropping all none-I-frames, it interpolates the missing frames to
produce the correct rate. BTW, I get less frames than the (my) source
video, because the muxers stops creating output at the last input
I-frame.

Another BTW: The value PICT_TYPE_I, which is also used in the Wiki
entry, does not correspond to the documentation which says:

> ‘pict_type (video only)’
>
>     The type of the filtered frame. It can assume one of the following values:
>
>     ‘I’
>     ‘P’
>     ‘B’
>     ‘S’
>     ‘SI’
>     ‘SP’
>     ‘BI’

But the source (libavfilter/f_select.c) tells me that the prefix
PICT_TYPE_ is also accepted.

Moritz


More information about the ffmpeg-user mailing list