ffmpeg AVCodec 和 AVCodecContext 用法

AVCodec 

avcodec_register_all 注册解码器

AVCodec *avcodec_find_decoder(enum AVCodecID id) 初始化 解码器

AVCodec *avcodec_find_decoder_by_name(const char *name) 通过名字来查找解码器。andoird cpu中集成有专门处理音视频的部分,且只提供了java的接口,这里要通过ffmpeg来调用java代码实现。

如:

AVCodec *avcodec_find_decoder_by_name(“h264_mediacodec"); 

AVCodecContext 

AVCodecContext 是解码器的上下文,解码时候需要用到。

AVCodecContext * avcode_alloc_context3(const AVCodec *codec)

初始化解码器上下文

 

void avcodec_free_context(AVCodecContext ** avcodecContext)

释放解码器上下文

 

int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **option)

打开解码器,option是key value值,在libavcodec/options_table.h 中。

 

配置多线程进行解码,里面有个参数int  thread_count 来进行。

 avCodecContext->thread_count = 1;

 

time_base , 传过来的pts不变,可以用 stream里的time_base与数据源一致。

 

int avcodec_parameters_to_context(AVCodecContext *codec,const AVCodecParameters *par);

将stream流中的 codec的parameters 拷贝到AVCodecContext中,AVStream中弃用了 AVCodecde的替换方法

    AVCodec *avCodec = avcodec_find_decoder(ic->streams[videoStream]->codecpar->codec_id);
    AVCodecContext*avCodecContext = avcodec_alloc_context3(avCodec);
    avcodec_parameters_to_context(avCodecContext, ic->streams[videoStream]->codecpar);

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值