h264 annexb bitstream to flv mux ffmpeg library

你。 提交于 2019-12-21 05:15:40

问题


I have an IP Camera which gives H264 annexb Bitstream through SDK calls. I want to pack this video stream into FLV container. So far I've got to know the following :-

I have to convert H264 annexb to H264 AVCC : For this I'll have to replace NAL header byte (0x00000001) with Size of NALU (big endian format).

My question is, What do I do with SPS and PPS ? should I write (av_interleaved_write_frame) them as are after replacing the NAL header ? or do I not write these frames at all ?

I read about AVCC requiring extra data. How do I construct that ? where do I pass that ?


回答1:


First retrieve the SPS/PPS from the camera. Write the SPS/PPS to AVCC extradata format (see how to here: Possible Locations for Sequence/Picture Parameter Set(s) for H.264 Stream)

Set AVCodecContext.extradata

void *extradata = /**/;
int extradata_size = /**/;
codecCtx->extradata_size = extradata_size;
codecCtx->extradata = av_malloc ( codecCtx->extradata_size );
memcpy ( codecCtx->extradata, extradata, codecCtx->extradata_size);

Before calling avcodec_open2



来源:https://stackoverflow.com/questions/29751805/h264-annexb-bitstream-to-flv-mux-ffmpeg-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!