使用ffmpeg读取实时视频流时,pFormatCtx-> streams [i]-> codecpar
是 0x00 ,而pFormatCtx-> streams [i]
是 0x55555579bbc0。
我的源代码如下,其中if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
//open media file
if (avformat_open_input(&pFormatCtx, url, NULL, &avdic) != 0) {
std::cout<<"can't open the file. \n";
return;
}
//find the infomation of the stream
if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
std::cout<<"Could't find stream infomation.\n";
return;
}
//find the parameters of the video stream
int videoStream = -1;
cout<<pFormatCtx->nb_streams<<endl;
for (unsigned int i = 0; i < pFormatCtx->nb_streams; i++) {
if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
videoStream = i;
}
}
if (videoStream == -1) {
std::cout<<"Didn't find a video stream.\n"<<std::endl;
return;
}
答案 0 :(得分:0)
通过将服务器系统升级到<a href="{% url 'calc:unit' unit.id %}">{{ unit.unit_name }}</a>
来解决此问题,原因是旧系统Ubuntu 20.04
无法正确链接ffmpeg动态库