[Ffmpeg-devel] Help understanding AVParser

Cool_Zer0 c00jz3r0
Wed Dec 20 10:55:15 CET 2006


On 12/20/06, Cool_Zer0 <c00jz3r0 at gmail.com> wrote:
>
>
> Michael Niedermayer wrote:
> > Hi
> >
> > On Tue, Dec 19, 2006 at 09:59:00AM +0000, Cool_Zer0 wrote:
> >
> >> Michael Niedermayer wrote:
> >>
> >>> Hi
> >>>
> >>> On Mon, Dec 18, 2006 at 06:37:22PM +0000, Cool_Zer0 wrote:
> >>>
> >>>
> >>>> On 12/18/06, Michael Niedermayer <michaelni at gmx.at > wrote:
> >>>>
> >>>>
> >>>>> Hi
> >>>>>
> >>>>> On Mon, Dec 18, 2006 at 11:04:47AM +0000, Cool_Zer0 wrote:
> >>>>>
> >>>>>
> >>>>>> Hi there.
> >>>>>>
> >>>>>> I'm trying to use AVParser but I'm a bit lost and I can't find any
> >>>>>> documentation.
> >>>>>>
> >>>>>> So... Here's what I'm doing...
> >>>>>>
> >>>>>>
> >>>>>> I'm calling *av_parser_init(CODEC_ID_H263)* and then I think that I
> have
> >>>>>>
> >>>>>>
> >>>>> to
> >>>>>
> >>>>>
> >>>>>> call *av_parser_parse()* for each H.263 packet that I receive.
> >>>>>> My main problem is understanding the parameters of the last
> function:
> >>>>>>
> >>>>>> AVCodecParserContext
> >>>>>> AVCodecContext
> >>>>>> poutbuf
> >>>>>> poutbuf_size
> >>>>>> buf
> >>>>>> buf_size
> >>>>>> pts
> >>>>>> dts
> >>>>>>
> >>>>>> The first ones I understand but the last 6 I can't understand what
> they
> >>>>>> are...
> >>>>>> Other question...  If buf_size takes the value 0 it means that I
> have a
> >>>>>> complete frame, right? So... Where is that frame and how can I put
> on a
> >>>>>> AVFrame/AVPicture in order to convert it to BGR24?
> >>>>>>
> >>>>>> If you don't want to answer my question at least give me some link
> to
> >>>>>>
> >>>>>>
> >>>>> any
> >>>>>
> >>>>>
> >>>>>> documentation about AVParser.
> >>>>>>
> >>>>>>
> >>>>> see av_read_frame_internal() in utils.c and the doxygen comment
> above
> >>>>> av_parser_parse in parser.c
> >>>>>
> >>>>>
> >>>> Hi.
> >>>> When I update my code the comment appear :)
> >>>> But I'm having the same problems that I had without the AVParser :(
> >>>>
> >>>>
> >>>> AVCodecParserContext *parser_context;
> >>>> uint8_t *poutbuf = new uint8_t[6000];
> >>>> int poutsize=0;
> >>>>
> >>>> {
> >>>> ...
> >>>> parser_context = av_parser_init(CODEC_ID_H263);
> >>>> ...
> >>>> }
> >>>>
> >>>> void video_decode(unsigned char* payload, int payloadsize)
> >>>> {
> >>>>   static int frame_numero = 0;
> >>>>
> >>>>   int len = 0;
> >>>>   while (payloadsize) {
> >>>>       len = av_parser_parse(parser_context, c, &poutbuf, &poutsize,
> >>>> payload, payloadsize, frame_numero, frame_numero);
> >>>>
> >>>>       payload += len;
> >>>>       payloadsize -= len;
> >>>>
> >>>>       if (len < 0)
> >>>>           return;
> >>>>
> >>>>
> >>>
> >>>
> >> Hi.
> >>
> >>
> >>> if(!poutsize)
> >>>    continue;
> >>>
> >>>
> >> Less frames are saved but still presents the same problems :(
> >>
> >>
> >>> and if this doesnt help then does it work if you dump the stuff to a
> file
> >>> and
> >>> try to play that with ffmpeg or ffplay?
> >>>
> >>>
> >> That's a good sugestion!!! If ffmpeg could play and decompress the
> movie
> >> correctly should mean that the problem is in my code. There is only one
> >> problem...
> >> I'm receiving packets through RTP (not using RTSP)... I have saved
> about
> >> 160 h.263 packets... In order to pass that packets to ffmpeg what I
> have
> >> to do? Merge all the packets into a single file? It will work? The file
> >> doesn't need to have a special format?
> >>
> >
> > yes ff* should be able to play h.263 if the frames are just concatenated
> >
> >
>
> Hummmmm...
> But when I decompress I get a YUV420P frame, right?
> To make a .avi of YUV420P frames I have to convert them to another
> format before the concatenation, right? Can you sugest me other format?
>


I forgot to say one thing... I've tested the concatenation of the packets
but it doesn't work...
Take a look at this code:

void decompress() {

    FILE *f; // file pointer to the rtp packet
    FILE *destino; // file pointer to the destionation file (concatenate)
    destino = fopen("compressed.avi", "ab");

    char filename[200];
    unsigned char buffer[10000];
    int read;
    for (int i=0; i<125; i++) { // I have saved 125 packets that I received
from RTP (I've already extracted the RTP Headers)
        sprintf(filename, "0%d_frame.raw", i);
        f = fopen(filename, "rb");

        if (f != NULL) {
            read = fread(buffer, 1, sizeof(buffer), f);
            fwrite(buffer,1,read,destino); // concatenate
            fclose(f);

        }
    }

    fclose(destino);
}


Then I tried to used ffmpeg:
$ ffmpeg -i compressed.avi -vcodec mpeg1video tt.mpg
FFmpeg version SVN-r7330, Copyright (c) 2000-2006 Fabrice Bellard, et al.
  configuration:  --enable-shared --disable-static --enable-memalign-hack
  libavutil version: 49.1.0
  libavcodec version: 51.27.0
  libavformat version: 51.6.0
  built on Dec 19 2006 14:50:58, gcc: 3.4.5 (mingw special)
[mp3 @ 6C356054]Could not find codec parameters (Audio: mp2, 96 kb/s)
compressed.avi: could not find codec parameters


I've tried other combinations like
$ ffmpeg -i -vcodec h263 compressed.avi -vcodec mpeg1video tt.mpg
FFmpeg version SVN-r7330, Copyright (c) 2000-2006 Fabrice Bellard, et al.
  configuration:  --enable-shared --disable-static --enable-memalign-hack
  libavutil version: 49.1.0
  libavcodec version: 51.27.0
  libavformat version: 51.6.0
  built on Dec 19 2006 14:50:58, gcc: 3.4.5 (mingw special)
-vcodec: I/O error occured
Usually that means that input file is truncated and/or corrupted.


But any have worked...
:(

We must be really dumb... I have three more people working in this project
and any of us can understand what can make the frames look like
http://student.dei.uc.pt/~ncenteio/ffmpeg/raw_images.bmp


...If anyone could help...


> and you can generate a valid h.263 file for comparission with
> > ffmpeg -i any.avi -s 352x288 test.h263
> >
> > [...]
> >
> >
>
>
> Thanks again for your patience.
>




More information about the ffmpeg-devel mailing list