h264: mp4 to annexb in ffmpeg



h264有两种封装,

一种是annexb模式,传统模式,有startcode,SPS和PPS是在ES中

一种是mp4模式,一般mp4 mkv会有,没有startcode,SPS和PPS以及其它信息被封装在container中,每一个frame前面是这个frame的长度


很多解码器只支持annexb这种模式,因此需要将mp4做转换:


在ffmpeg中用h264_mp4toannexb_filter可以做转换


实现:

注册filter

avcbsfc = av_bitstream_filter_init("h264_mp4toannexb");

转换bitstream

av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
                               AVCodecContext *avctx, const char *args,
                     uint8_t **poutbuf, int *poutbuf_size,
                     const uint8_t *buf, int buf_size, int keyframe)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章