Migrating to Libav10

When in doubt about the proper way to replace old API usage, consult the doc/APIchanges file in the source directory and/or ask on the user IRC channel.

Removed APIs

API removed in Libav 9


They had been replaced by avformat_open_input.


It had been replaced with avformat_find_stream_info.

avcodec resampler

av_resample* and all related APIs have been dropped. Applications are supposed to use libavresample instead.

audio decoding API

The deprecated avcodec_decode_audio3() API function has been removed. avcodec_decode_audio4() must be used instead.

The old function decodes straight into a provided int16_t data buffer. This has some limitations, such as:

The new function decodes into an AVFrame, which solves all of those problems. The most naive and straightforward conversion from the old code to the new code is:

This will only work for interleaved sample formats, i.e. if av_sample_fmt_is_planar(avctx->sample_fmt) returns 0. For planar sample formats, you can either

Audio and video encoding APIs

The deprecated avcodec_encode_audio() and avcodec_encode_video() functions have been removed. avcodec_encode_audio2() and avcodec_encode_video2() must be used instead.

The old audio and video functions take a plain short data buffer and an AVFrame, respectively, as input and encode into a plain uint8_t data buffer provided by the caller. This has a number of limitations, such as:

The new functions have the same signature and semantics for both audio and video, and solve all of those problems. They take an AVFrame as input and produce an AVPacket as output. The output packet can be allocated by the encoder, which ensures that the correct amount of space is provided. Since most current callers of the libavcodec encoding API then pass the encoded data to libavformat for muxing, the simplest way to migrate to the new API is


Along with the previously mentioned audio encoding and decoding APIs, the AVCODEC_MAX_AUDIO_FRAME_SIZE macro was also removed. The reasons for that are:

So in the context of the new APIs, AVCODEC_MAX_AUDIO_FRAME_SIZE is just an arbitrary number without any well-defined meaning, and this is why it was removed.

We have seen may callers simply replace this macro with the value 192000 it used to have. This solution is in the vast majority of cases a sub-optimal (or even outright wrong) one. The correct solutions for the majority of users would be:


This field was basically never used for its intended purpose, thus it was deprecated and removed. The callers should use avg_frame_rate instead.


Should be replaced with avformat_close_input(&context) (note that the pointer to the pointer to the context is passed to the function, so & must be applied to the parameter previously used for av_close_input_file()).

Changed functionality

Reference counted AVPackets

Macro namespace change


Consistent Frame Management

Code move