问题
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