User Tools

Site Tools


ffmpeg:avcodec_open

avcodec_open

Overview

Defined in avcodec.h

Initializes the AVCodecContext to use the given AVCodec. Prior to using this function the context has to be allocated.

The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for retrieving a codec.

WARNING: This function is not thread safe!

Example:

avcodec_register_all();
 
codec = avcodec_find_decoder(CODEC_ID_H264);
if (!codec) exit(1);
 
context = avcodec_alloc_context();
if (avcodec_open(context, codec) < 0) exit(1);
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);

Parameters

avctx

AVCodecContext *avctx

The AVCodecContext which will be set up to use the given codec.

codec

AVCodec *codec

The AVCodec to use within the context.

Return value

Zero on success, a negative value on error

See also

ffmpeg/avcodec_open.txt · Last modified: 2007/11/26 12:08 by deva