c - libavformat/ffmpeg C 程序 "not suitable input format"

标签 c ffmpeg libavcodec libav libavformat

您好,我正在尝试使用 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/

相关文章:

ffmpeg - 使用 libavcodec 时模拟 FFMPEG '-sameq' 标志所需的设置

c - 从双变量获得奇怪的结果 (C)

c - 数据结构/记录

c - 迷宫死端过滤器检查

ffmpeg - 如何在 FFMPEG 中制作具有静态图像背景的视频?

c++ - 使用 FFMPEG 库到 UDP 流 mpeg2 ts 视频延迟/初始连接问题

c++ - 未定义对 avcodec_alloc_context 的引用但 ffmpeg 链接器顺序正确吗?

c++ - 错误 C2057 : expected constant expression

ffmpeg - 如何使用 FFMPEG(延迟不是问题)在不缓冲的 Azure 媒体播放器中获得连续直播?

ffmpeg - 像 CODEC_FLAG2_BPYRAMID 这样的 ffmpeg 标志位于哪里?