首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ffmpeg读取视频时面临分割错误,因为"pFormatCtx-> streams [i]-> codecpar的地址为0x00

使用ffmpeg读取视频时面临分割错误,因为"pFormatCtx-> streams [i]-> codecpar的地址为0x00
EN

Stack Overflow用户
提问于 2019-12-27 14:53:02
回答 1查看 281关注 0票数 0

使用ffmpeg读取实时视频流时,pFormatCtx-> streams [i]-> codecpar0x00,但pFormatCtx-> streams [i],我的源代码如下所示,在if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)行中出现错误

代码语言:javascript
复制
    //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;
    }
EN

回答 1

Stack Overflow用户

发布于 2019-12-30 02:07:14

通过将我的服务器系统升级到Ubuntu 20.04来解决这个问题,原因是旧的系统18.04不能正确地链接ffmpeg动态库

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59502424

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档