[Libav-user] convert MP4 frames to Annex B
Selmeci, Tamas
tselmeci at open-st.eu
Fri Jul 18 16:36:27 CEST 2014
On Fri, 2014-07-18 at 14:59 +0200, Selmeci, Tamas wrote:
> Doing something like this simply doesn't filter the input buffer:
>
> int out_size;
> uint8_t *out;
> AVPacket packet;
> AVCodec *codec;
> AVCodecContext *codec_ctx;
> AVBitStreamFilterContext *annexb;
>
> annexb = av_bitstream_filter_init("h264_mp4toannexb");
>
> av_read_frame(context, &packet);
> av_read_frame(context, &packet);
> ...
> codec = avcodec_find_decoder(AV_CODEC_ID_H264);
> codec_ctx = avcodec_alloc_context3(codec);
> avcodec_open2(codec_ctx, codec, NULL);
> av_bitstream_filter_filter(annexb,
> codec_ctx,
> NULL,
> &out,
> &out_size,
> packet.data,
> packet.size,
> packet.flags & AV_PKT_FLAG_KEY);
> avcodec_close(codec_ctx);
> av_free(codec_ctx);
> av_bitstream_filter_close(annexb);
Okay, I've figured it out. The above is wrong, you don't have to create
a codec context, instead must use the codec context in
AVFormatContext::streams[idx]::codec. And it's now working perfectly ;)
Regards,
--
Selmeci, Tamás
http://www.open-st.eu/
More information about the Libav-user
mailing list