avformat_open_input返回错误-22(Invalid argument)或-2(No such file or directory)

7 篇文章 0 订阅

代码

    AVFormatContext *pFormatCtx = NULL;
    AVCodecContext *pCodecCtx = NULL;
    AVCodec *pCodec;
    AVDictionaryEntry *dict = NULL;

    int iHour, iMinute, iSecond, iTotalSeconds;//HH:MM:SS
    int videoIndex, audioIndex;

    const char* fileName = "D:\\code\\ffmpeg\\ffmpeg-20191028-68f623d-win64-dev\\FfmpegDemo\\YY.mp4";

    //char *fileName = "Titanic.ts";

    av_register_all();//注册所有组件
    avformat_network_init();
    int ret = 0;
    ret = avformat_open_input(&pFormatCtx, fileName, NULL, NULL);

    if (ret != 0)//打开输入视频文件
    {
        char msg[512];
        av_make_error_string(msg, 512, ret);
        printf("Couldn't open input stream. Error(%d)(%s).\n", ret, msg);
        return -1;
    }

-2 No such file or directory 原因,很简单就是文件路径错误,如果还不行,可以试试全局路径。

-22 Invalid argument 原因,输入有误,比如在路径中,只写了一个反斜杠,而不是两个,可以参见代码中的路径格式重写。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值