[FFmpeg-devel] frame type identification question

Stefano Sabatini stefano.sabatini-lala
Sun Oct 14 18:12:01 CEST 2007

On date Sunday 2007-10-14 09:12:30 -0400, Victor lyamtsev encoded:
> Hello,
> I am trying to write utility to remove certain frames from H264 file ( all
> B- frames, for example ) .
> E.g. it should copy original into new H264 file, excluding B-frames.
> I wonder how I can find frame type identifier after reading of frame...
> av_read_frame( pFormatContext, &packet)
> I assume it's somewhere within AVPacket struct... How to retreive it?
> Thank you,

I'm not sure you can detect the type of frame without to actually
*decode* it (but you can still check if the frame is a key frame by
reading the flags in the AVPacket).

For example:

/* decode the data from the packet and put the resulting picture in picture)
ret = avcodec_decode_video(ist->st->codec, &picture, &got_frame, pkt_data_ptr, pkt_data_len);
if (ret < 0)
if (got_picture && picture.pict_type == B_TYPE) {
} else {

By the way: this is a question more for ffmpeg-user than for ffmpeg-devel.

Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)

More information about the ffmpeg-devel mailing list