【问题标题】:The function avformat_open_input from ffmpeg lib cann't open fileffmpeg lib中的函数avformat_open_input无法打开文件
【发布时间】:2011-11-09 10:16:03
【问题描述】:

我尝试使用 ffmpeg lib 从我的代码中打开文件。并且 avformat_open_input 总是收到错误“没有这样的文件或目录”。我尝试了不同的文件和目录,但结果都是一样的。

我在 Win7 上使用 VS 2010 并从 http://ffmpeg.zeranoe.com/builds/ 编译 lib 和 dll

我的一些代码。

int decode_sound(const char * infile, const char * outfile) 
{
    AVFormatContext *pFormatCtx = 0;
    if((err = avformat_open_input(&pFormatCtx, infile, NULL, 0)) != 0)
       return 1;
}


int _tmain(int argc, _TCHAR* argv[])
{
    avcodec_register_all();

    cout << decode_sound("D:\\DELTA.MPG", "D:\\wav.wav") << endl;

    char errbuf[128];
    const char *errbuf_ptr = errbuf;
    if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
          strerror_s(errbuf, AVUNERROR(err));
    cout << err << endl << errbuf_ptr << endl;

    system("pause");
    return 0;
}

【问题讨论】:

    标签: visual-c++ ffmpeg


    【解决方案1】:

    我知道这是一个老问题,但是这个

    int _tmain(int argc, _TCHAR* argv[])
    

    是你的问题。 Windows 正在传递一个宽字符字符串,而您将其转换为一个字符字符串,因此 ffmpeg 只看到它的第一个字节。将其更改为

    int main(int argc, char* argv[])
    

    会解决的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-21
      • 2012-11-10
      • 1970-01-01
      相关资源
      最近更新 更多