LibAV is an open source library that implements many video encoders and decoders.  These are all abstracted through a common API so using any of the supported encoders and decoders looks about the same to the user application.  The first step is to find the encoder or decoder by ID to get a pointer to its AVCodec data.  Each LibAV ID represents a supported codec, so this step is selecting which codec to use.  The AVCodec data can be used to allocate a context for the encoder or decoder which is returned as an AVCodecContext pointer.  The context can be configured and then opened.  If opening is successful, the context is ready to use for video encoding or decoding.

Data is transferred between LibAV and the user application through the AVPacket and AVFrame objects.  AVPacket is for bitstream data, and AVFrame is for raw un-compressed media.  For video, each AVFrame object will contain one still image that can be displayed.  AVFrame supports a wide variety image formats with different pixel formats, color spaces and plane structures.  In general, each codec supported by LibAV will use a specific image format that the user application will receive from decoders and must provide to encoders.  LibAV itself does not support image format conversion, so a separate library is needed if the image format must be changed.

LibAV Encode Decode