您好,我正在尝试使用 C ffmpeg 库对视频进行编码。由于某种原因,当我尝试创建格式上下文时出现错误:
[NULL @ 0x7ff574006600] 请求的输出格式“mp4”不是合适的输出格式
我知道我的 ffmpeg 是使用 x264 标志编译的,就像一个简单的
ffmpeg -i test.mov test.mp4
工作正常。我还链接了所有生成的 pch 文件,并且 libav* 库中的其他所有内容都工作正常。这是一个完整的工作示例,其中包含我收到的错误:
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
#include <libavutil/opt.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
#include <stdio.h>
int main() {
AVFormatContext * output = NULL;
// now lets initialize the actual format element
if (avformat_alloc_output_context2(&output, NULL, "mp4", "test.mp4") < 0) {
printf("%s", "INVALID");
}
return 0;
}
最佳答案
你必须打电话
av_register_all();
在分配输出上下文之前。
关于c - libavformat/ffmpeg C 程序 "not suitable input format",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19145443/