FFmpeg 解码 avcodec_find_decoder AVCodecContext

本文详细介绍了FFmpeg解码过程,包括使用avcodec_find_decoder查找解码器,通过AVCodecContext进行解码器配置,以及AVFrame在解码过程中的作用。重点讲解了avcodec_send_packet和avcodec_receive_frame的配合使用,强调了解码过程中可能遇到的问题及解决策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

avcodec_find_decoder

(1)解码模块第一步:获取解码器 avcodec_find_decoder()FFmpeg的解码器编码器都存在avcodec的结构体中
(2) 解码前保证用到的解码器已经注册好 avcodec_register_all();(过期)
(3)通过解封装之后,从avstream里面获取CodecID ,通过CodecID来查找decoder AVCodec *avcodec_find_decoder(enum AVCodecID id)
AVCodec 存放的是解码器格式的配置信息
(4)通过解码器名字找到解码器 AVCodec *avcodec_find_decoder_by_name(const char
*name);
如:avcodec_find_decoder_by_name(“h264_mediacodec”);

AVCodecContext

(1) AVCodecContext *avcodec_alloc_context3(const AVCodec *codec) 空间申请

(2)void avcodec_free_context(AVCodecContext **avctx); 释放

(3)int avcodec_open2(AVCodecContext *avctx, const AVCodec
*codec, AVDictionary **options) 打开 options动态设置 多线程解码设置
• /libavcodec/options_table.h
• int thread_count CPU数量设置
• time_base 时间基数
(4)avcodec_parameters_to_context(codec, p); 把avstream中的参数复制到codec中

  //解码器初始化
    AVCodecContext *vc = avcodec_a
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值