H.264 annex B muxing in mp4

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

H.264 annex B muxing in mp4

malikcis
Hi,
I managed to write a H.264 annex B muxer (from a compression board) in mp4 using libavformat.
If I don’t specify extradata as bellow, the generated MP4 stream appears to be corrupted and won’t play in quicktime.
pMux_ctx->video_st = NULL;  
if ( pMux_ctx->fmt->video_codec != CODEC_ID_NONE )
{  
                AVCodecContext * c;  
                pMux_ctx->video_st = av_new_stream (pMux_ctx->oc , 0);  
                if (! pMux_ctx->video_st)
                {  
                               fprintf( stderr, "Could not alloc video_stream\n" );  
                               exit(1);  
                }  
                c = pMux_ctx->video_st->codec;  

c->extradata = buffer;
c->extradata_size = size;

}
This all works fine but I just don’t understand why the muxer needs the extradata since all necessary metadata have already been set through AVCodecContext.
I would like to simplify the code and avoid computing extradata in advance (saving thus 600 lines of code).
Thanks, Malikcis