c - libav - 对 'av_frame_alloc' 等的 undefined reference

标签 c ffmpeg libavcodec libav libavformat

我正在尝试从 libav 文档编译本教程:link

我没有对代码进行任何更改!

但是当我编译它时:

gcc test.c -lavformat -lswscale -lavdevice -lavformat -lavcodec -lavutil -lpthread -lm -o example

我收到这些错误:

undefined reference to `check_sample_fmt'
undefined reference to `select_sample_rate'
undefined reference to `select_channel_layout'
undefined reference to `av_frame_alloc'
undefined reference to `av_frame_free'

搜索 Dr.google 我读到它可能与库的链接顺序有关。但我还没找到正确的?!

编辑: 这个“可能的重复”似乎与我的问题无关

最佳答案

您可能正在使用较新版本的 FFmpeg 运行旧代码。 FFmpeg 更改了一些函数名称,一些函数会产生一些折旧警告,而另一些则会产生错误。

据官方Ffmpeg github :

av_frame_alloc(), av_frame_unref() and av_frame_free() now can and should be 
used instead of avcodec_alloc_frame(), avcodec_get_frame_defaults() and avcodec_free_frame() respectively

关于c - libav - 对 'av_frame_alloc' 等的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32003683/

相关文章:

ffmpeg - 如何使用 FFMPEG 获取视频的 _current_ 持续时间? (不是元数据)

audio - 针对小文件大小的 libav/ffmpeg 输出优化

c - 从 .txt 文件中读取整行并将特定信息存储到不同的字符串中

c - 如果我的编译器对函数指针的支持被破坏,我该如何编写一个调度程序?

video - ffmpeg 在 sws_scale() 中从 YUV 到 RGB 的效果较差(为 : ffmpeg blocky chroma decoding)

video - 使用 ffmpeg 进行 GPU 加速视频处理

windows - 从 Windows 中的空闲后台应用程序获取标准输出

c++ - 指向无效内存时 sizeof(*ptr) 的行为是否未定义?

c - 临时文件与 malloc(在 C 中)

ffmpeg - 关键帧不是关键帧? AV_PKT_FLAG_KEY 未解码为 AV_PICTURE_TYPE_I