tags:

views:

131

answers:

2

Hi, i'm developing a video server in C on GNU/Linux, and i'm using ffmpeg to manage data of each video file. So, i open the file, get all the information about its container, then do the same with its codec and start reading frames one by one.

Unfortunately, ffmpeg and more precisely avcodec is not very well documented. I need to know when a frame is an I-Frame or a B-Frame to maintain a record, so how could i do it?

Thanks in advance.

A: 

Manuel,

Have you tried FF-probe yet? It is a multimedia streams analyzer that allows you to see the type of each frame. You can download it from SourceForget.net. To compile it you will need Gnu autoconf, a C compiler and a working installation of the FFmpeg. Let me know if that helps.

jdecuyper
Thanks, i'll have a look at the source code.
Manuel Abeledo
+1  A: 

The picture type is given by the pict_type field of struct AVFrame. You have 4 types defined in FFMPEG. pict_type is set to FF_I_TYPE for I Frames.

For example, part of my debug code which give me a letter to set in a debug message :

/* _avframe is struct AVFrame* */

switch(_avframe->pict_type)
{
    case FF_I_TYPE:
        return "I";
        break;
    case FF_P_TYPE:
        return "P";
        break;
    case FF_S_TYPE:
        return "S";
        break;
    case FF_B_TYPE:
        return "B";
        break;

}
neuro
Thanks! That's *exactly* what i need. I've been using keyframes as for now, but identifying all types is very useful.
Manuel Abeledo
You're welcome ;) Good luck with your code ...
neuro