解码(二):音视频解码上下文创建配置和打开avcodec_open2打开演示

本文详细介绍了在音视频处理中如何创建和配置解码上下文,并通过avcodec_open2函数成功打开解码器的过程,是理解音视频解码流程的关键步骤。
摘要由CSDN通过智能技术生成

如下代码:

/
	///视频解码器打开	
	///找到视频解码器
	AVCodec *vcodec = avcodec_find_decoder(ic->streams[videoStream]->codecpar->codec_id);

	if (!vcodec)
	{
		cout << "can't find the codec id" << ic->streams[videoStream]->codecpar->codec_id << endl;
		getchar();
		return -1;
	}
	cout << "find the video AVCodec" << ic->streams[videoStream]->codecpar->codec_id << endl;

	///创建解码器上下文
	AVCodecContext *vc = avcodec_alloc_context3(vcodec);
	///配置解码器上席文参数
	avcodec_parameters_to_context(vc, ic->streams[videoStream]->codecpar);
	//8线程解码器
	vc->thread_count = 8; 
	///打开解码器上下文
	re = avcodec_open2(vc, 0,0);
	if (re != 0)
	{
		char buffer[1024];
		av_strerror(re, buffer, sizeof(buffer - 1));
		cout << "avcodec open failed" << buffer << endl;
		getchar();
		return -1;
	}
	cout << "video avcodec open success" << endl;	
	
	/
	///音频解码器打开
	//
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值