AVCodecContext

简要描述
  • 描述一个编解码器的内容空间
参数
参数名 类型 说明
codec_type enum AVMediaType 编解码器的类型(视频,音频…)
codec struct AVCodec 采用的解码器AVCodec(H.264,MPEG2…)
bit_rate int 平均比特率
time_base AVRational 根据该参数,可以把PTS转化为实际的时间(单位为秒s)
width,height int 如果是视频的话,代表宽和高
sample_rate int 采样率(音频)
channels int 声道数(音频)
channel_layout uint64_t 音频通道布局
sample_fmt enum AVSampleFormat 采样格式
使用方法
    AVCodecContext *pCodecCtx = pFormatCtx->streams[streamIdx]->codec;
    AVCodec* pCodec = avcodec_find_decoder(pCodecCtx->codec_id);

    //编解码器类型
    enum AVMediaType {
        AVMEDIA_TYPE_UNKNOWN = -1,  ///< Usually treated as AVMEDIA_TYPE_DATA
        AVMEDIA_TYPE_VIDEO,
        AVMEDIA_TYPE_AUDIO,
        AVMEDIA_TYPE_DATA,          ///< Opaque data information usually continuous
        AVMEDIA_TYPE_SUBTITLE,
        AVMEDIA_TYPE_ATTACHMENT,    ///< Opaque data information usually sparse
        AVMEDIA_TYPE_NB
    };

    //音频采样格式
    enum AVSampleFormat {
        AV_SAMPLE_FMT_NONE = -1,
        AV_SAMPLE_FMT_U8,          ///< unsigned 8 bits
        AV_SAMPLE_FMT_S16,         ///< signed 16 bits
        AV_SAMPLE_FMT_S32,         ///< signed 32 bits
        AV_SAMPLE_FMT_FLT,         ///< float
        AV_SAMPLE_FMT_DBL,         ///< double
        AV_SAMPLE_FMT_U8P,         ///< unsigned 8 bits, planar
        AV_SAMPLE_FMT_S16P,        ///< signed 16 bits, planar
        AV_SAMPLE_FMT_S32P,        ///< signed 32 bits, planar
        AV_SAMPLE_FMT_FLTP,        ///< float, planar
        AV_SAMPLE_FMT_DBLP,        ///< double, planar
        AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if linking dynamically
    };