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)

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