无法通过avformat_open_input输入.mp3

时间:2019-10-27 17:04:13

标签: c ffmpeg

我正在尝试使用ffmpeg库构建一些C程序。 但是,我什至无法使用avformat_open_input()打开音频文件 设置了检查错误代码的功能后,我得到以下输出:

Error code: -1094995529
Invalid data found when processing input

不是

Error code: -2
No such file or directory

当我没有指定正确的文件名时。

查询了此错误代码的含义后,我假设mp3文件的标头中肯定缺少avformat_open_input()需要识别其扩展名的信息。

我尝试打开不同的mp3文件甚至不同的格式。但是我仍然遇到相同的错误。

这是我的主要

const char *url = NULL;
AVFormatContext *s = NULL;
int ret = 0;
if (ac == 2)
    url = av[1];
else
    return (1);
ret = avformat_open_input(&s, url, NULL, NULL);
if (ret < 0) 
{
    check_error(ret);
    abort();
}

知道我在做什么错吗?

谢谢

1 个答案:

答案 0 :(得分:1)

您需要先avformat_alloc_context()

也请检查文档中的the example code

相关问题