我正在尝试使用 ffmpeg 库构建一个小的 C 程序。
但是我什至无法使用 avformat_open_input()
打开音频文件
设置检查错误代码的函数后,我得到以下输出:
Error code: -1094995529
Invalid data found when processing input
而不是
Error code: -2
No such file or directory
当我没有指定正确的文件名时。
在查看此错误代码的含义后,我假设我的 mp3 文件在其 header 中一定缺少 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();
}
知道我做错了什么吗?
谢谢
最佳答案
您需要先avformat_alloc_context()
。
同时检查 the example code在文档中。
关于无法 avformat_open_input .mp3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58581552/