我按照步骤 here to compile FFmpeg.
而且没有问题。它运作良好。但我不明白一些事情。
我的主目录下有两个文件夹。
--ffmpeg_sources
--ffmpeg_build
在 ffmpeg_sources/libavformat 中,我有很多标题
aiff.h
apetag.h
argo_asf.h
asfcrypt.h
asf.h
ast.h
av1.h
avc.h
avformat.h
avi.h
avio.h
avio_internal.h
avlanguage.h
ogg.h
...
但 ffmpeg_build/avformat 有 3 个 header 。avformat.h
avio.h
version.h
顺便说一句,这是我的 usr/include/x86_64-linux-gnu/libavformatavformat.h
avio.h
version.h
为什么这两个文件中的所有标题都不包含?例如:我想使用“ogg_read_packet”但是当我尝试
include <libavformat/oggdec.h>
我得到 cannot open source file "libavformat/oggdec.h"C/C++(1696)
错误。
最佳答案
构建和使用库不是一回事。
看看 libavformat/oggdec.h 和 libavformat/oggdec.c 。您应该已经意识到,没有办法直接使用 ogg_read_packet
函数。
如果您想使用特定的编解码器(此处为 ogg)进行编码/解码,您必须找到一个编码器(avcodec_find_encoder 或 avcodec_find_encoder_by_name)或解码器(avcodec_find_decoder 或 avcodec_find_decoder_by_name)并通过 AVCodecContext 将其链接到 avcodec_open2。
然后使用 here 描述的“编码”函数进行编码,使用 here 描述的“解码”函数进行解码。
欲了解更多信息:
简而言之,使用公共(public)接口(interface)。只有“上帝”知道 FFmpeg 的内部结构。
关于c - ffmpeg - 缺少 avformat header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65560061/