无法 avformat_open_input .mp3

标签 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 文件在其 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/

相关文章:

c - Sprintf 连接字符串

video - VLC HLS 以 native 帧速率读取输入以进行实时流式传输

c - 我的 recovery.c 代码正确恢复 jpeg,但未通过 cs50 检查

node.js - 在 Node.js 中按设定时间分层 2 个音频文件

php - 使用 FFMPEG 转换为 FLV 的视频大小为 0

c# - 视频转换成flv

node.js - 通过 Node Js 使用 ffmpeg 添加时间戳叠加

c - 从 C SL 函数将值返回到 Progress 4GL

c - 连续内存空间中的链表

c - PortAudio - 在单声道中工作,在立体声中出现故障?