[Libav-user] decoding h264

luigi lgiancri at tiscali.it
Fri Sep 6 19:33:16 CEST 2013


Hi, I have problems decoding h264 video chunks included in a Mp4 video.
As far as I know nal units start with 0x000001 identifier. So I manage 
to parse mp4 video, spot the video chunks, re-parse the chunks to find 
nal unit identifier, then I reassemble the chunks and, finally, send the 
nal units to av_decode_video. In the code below, the nal unit buffer is 
tm_buf->buffer, its length is tm_buf->buf_len

     ...

     AVPacket *avpack        = &packet ;

     avpack->side_data     = NULL;
     avpack->side_data_elems = 0;
     avpack->data        = tm_buf->buffer;
     avpack->size        = tm_buf->buf_len;

     AVFrame *decoded_frame = NULL;

     if (!decoded_frame)
     {
         if (!(decoded_frame = avcodec_alloc_frame()))
         {
             fprintf(stderr, "Could not allocate audio frame\n");
             exit(1);
         }
     }
     else
         avcodec_get_frame_defaults(decoded_frame);

     len = avcodec_decode_video2( context, decoded_frame, &got_picture, 
avpack ) ;

Unfortunately the output window remains black.

I do not use av_read_frame to read from the file, because I want to 
rewrite the demuxer (as a matter of fact I already have). My knowledge 
of h264 is very poor, but why doesn't libav manage to decode the chunks. 
In addition, I don't seem to get any error message. Is there a way to 
solve all this without having to study all the stuff about h264?
Luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130906/fe0f5778/attachment.html>


More information about the Libav-user mailing list