h264附件比特流到flv mux ffmpeg库 [英] h264 annexb bitstream to flv mux ffmpeg library
问题描述
我想将此视频流打包成FLV容器。到目前为止,我必须知道以下内容: -
我必须将H264附件转换为H264 AVCC:
为此,我必须更换NAL标题字节(0x00000001),大小为NALU(大尾数格式)。
我的问题是,我用SPS和PPS做什么?我应该在替换NAL头后写(av_interleaved_write_frame)它们吗?或者我根本不写这些框架?
我看到有关AVCC需要额外的数据。如何构建?我在哪里通过?
首先从相机中检索SPS / PPS。将SPS / PPS写入AVCC extradata格式(请参阅以下内容: H.264流的序列/图片参数集的可能位置)
设置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);
调用 avcodec_open2
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 ?
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
这篇关于h264附件比特流到flv mux ffmpeg库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!