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

Rohit M powerohit at gmail.com
Tue Jan 6 10:08:31 CET 2015

I have successfully extracted the I P B frames from a video. But how to
preserve the frame number of the I P B frames.
Suppose I have the following GOP ..IPPPBPPP ... here frame one is I.
frame....second, third and fourth are P fifth is a B frame and sixth
seventh and eighth are once again P..... while extracting how can we name
the frames as 1I.jpg, 2P.jpg, 3P.jpg,  and so on....so that after
encrypting the I frames Iit should be possible place them back at the same

M S Rohit B.E, M.Tech,
Assistant Professor,
Dept of Computer Science & Engineering,
Jain Institute of Technology,

On Mon, Jan 5, 2015 at 3:55 PM, Moritz Barsnick <barsnick at gmx.net> wrote:

> 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
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user

More information about the ffmpeg-user mailing list