如下代码:
/
///视频解码器打开
///找到视频解码器
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;
/
///音频解码器打开
//