8

我们目前正在尝试升级我们程序使用的 ffmpeg 版本。跳跃很大,因为我们目前使用的是 ffmpeg 0.8,最新版本是 1.2。

在这些测试中,我使用了我在这里找到的(让我说)令人惊叹的包。

首先,我尝试下载和构建 ffmpeg 1.2,当然我收到了很多警告和错误,关于函数和变量已弃用或不再存在。

为了平滑过渡,我尝试构建 ffmpeg 1.0,这是与 0.8 最接近的更高版本。我得到了下面列出的警告和错误列表。

我的问题如下:是否存在任何指南来帮助这些过渡,在新版本中转换旧的 ffmpeg 范例/函数调用?由于我们正在谈论很多我没有编写的代码并且我不想逐行分析,如果可以将旧函数调用一对一转换为新函数调用,变量相同。

这是警告和错误列表(我已经清理了它,所以每个错误/警告只有一个条目)

warning: 'AVStream* av_new_stream(AVFormatContext*, int)' is deprecated (declared at /ffmpeg/include/libavformat/avformat.h:1646) [-Wdeprecated-declarations]

warning: 'int avcodec_open(AVCodecContext*, AVCodec*)' is deprecated (declared at /ffmpeg/include/libavcodec/avcodec.h:3569) [-Wdeprecated-declarations]
error: 'avcodec_init' was not declared in this scope
warning: 'int avcodec_encode_video(AVCodecContext*, uint8_t*, int, const AVFrame*)' is deprecated (declared at /ffmpeg/include/libavcodec/avcodec.h:4272) [-Wdeprecated-declarations]

warning: 'AVCodecContext* avcodec_alloc_context()' is deprecated (declared at /ffmpeg/include/libavcodec/avcodec.h:3423) [-Wdeprecated-declarations]

warning: 'int avcodec_decode_audio3(AVCodecContext*, int16_t*, int*, AVPacket*)' is deprecated (declared at /ffmpeg/include/libavcodec/avcodec.h:3852) [-Wdeprecated-declarations]

warning: 'void av_close_input_file(AVFormatContext*)' is deprecated (declared at /ffmpeg/include/libavformat/avformat.h:1622) [-Wdeprecated-declarations]
error: 'av_open_input_file' was not declared in this scope
warning: 'int av_find_stream_info(AVFormatContext*)' is deprecated (declared at /ffmpeg/include/libavformat/avformat.h:1446) [-Wdeprecated-declarations]
error: 'av_set_parameters' was not declared in this scope

error: 'AVFormatContext' has no member named 'file_size'

error: 'URL_WRONLY' was not declared in this scope

error: 'url_fopen' was not declared in this scope
error: 'url_fclose' was not declared in this scope

error: 'SAMPLE_FMT_U8' was not declared in this scope
error: 'SAMPLE_FMT_S16' was not declared in this scope
error: 'SAMPLE_FMT_S32' was not declared in this scope
error: 'SAMPLE_FMT_FLT' was not declared in this scope

error: 'FF_I_TYPE' was not declared in this scope


编辑:

我正在看这些...
http://ffmpeg.org/doxygen/0.8/deprecated.html
http://ffmpeg.org/doxygen/0.9/deprecated.html
http://ffmpeg.org/doxygen/ 1.0/deprecated.html
http://ffmpeg.org/doxygen/1.1/deprecated.html
http://ffmpeg.org/doxygen/1.2/deprecated.html
http://ffmpeg.org/doxygen/trunk/deprecated.html

4

2 回答 2

11

看看这里

URL_WRONLY -> AVIO_FLAG_WRITE
url_fopen -> avio_open
url_fclose -> avio_close

希望以上内容足以让您入门。


万一链接失效,这里是全文成绩单:

我找到了一些关于如何移植旧代码的资源(这里这里这里),但由于这不是我需要的,所以我决定编写自己的版本。所以,我们开始吧。

url_open()

此函数已更改为 avio_open。还有 url_close 被重命名为 avio_close。我在这里找到的这个信息。

av_new_stream()

自 FFMPEG 1.0.1 起仍支持此功能,但已标记为已弃用。它将被 avformat_new_stream() 替换。假设旧代码是:

AVStream *st = av_new_stream(oc, i);

修改后的代码应该是:

AVStream *st = avformat_new_stream(oc, NULL);
st->id = i

首先要小心检查 st 不是 NULL!

dump_format()

此函数已重命名为 av_dump_format()。

av_write_header()

替换为接受两个参数而不是一个参数的 avformat_write_header()。传递 NULL 作为第二个参数以获得与旧函数相同的行为。

av_codec_open()

这个替换为 av_codec_open2()。替换函数接受三个参数而不是两个参数,但将 NULL 作为第三个参数来获得与旧函数相同的行为。

avcodec_encode_audio()

替换为 avcodec_encode_audio2()。

av_set_parameters()

我不能很好地替换这个。首先,我发现这个功能没有替代品。但那是它在 FFMPEG 中仍然可用的时候,即使它已被弃用。然后,他们将其删除,因此必须进行更换。在某些地方我发现他们只禁用了它,在其他地方它的参数必须传递给 avformat_write_header。最后,我放弃了,因为我现在不需要那部分代码的工作版本。因为在我的例子中调用了 avformat_alloc_context(),然后调用了 av_set_parameters(),最后我看到的是调用 avformat_alloc_output_context2() 而不是 avformat_alloc_context()。但变化并非微不足道,所以我跳过了它。

SampleFormat

此枚举已重命名为 AVSampleFormat。

URL_WRONLY

此常量已替换为 AVIO_FLAG_WRITE。

SAMPLE_FMT_U8, SAMPLE_FMT_S16, SAMPLE_FMT_S32, etc.

这些现在以 AV_ 为前缀,因此请使用 AV_SAMPLE_FMT_U8、AV_SAMPLE_FMT_S16 等。

于 2013-07-09T19:24:00.210 回答
9

正如 Gabi 指出的那样,该 URL 具有大部分已弃用常量的替换。

但是,它缺少其中一些,因此我将发布您的输出表明完成此编译步骤所必需的所有更改:

avcodec_init -> avcodec_register_all
av_open_input_file -> avformat_open_input

在这里可能值得注意的是 av_set_parameters 已被弃用并完全废弃,因此您现在应该在对 avformat_open_input 的调用中指定参数。

AVFormatContext.file_size -> avio_size()
URL_WRONLY -> AVIO_FLAG_WRITE
url_fopen -> avio_open
url_fclose -> avio_close
SAMPLE_FMT_U8 -> AV_SAMPLE_FMT_U8
SAMPLE_FMT_S16 -> AV_SAMPLE_FMT_S16
SAMPLE_FMT_S32 -> AV_SAMPLE_FMT_S32
SAMPLE_FMT_FLT -> AV_SAMPLE_FMT_FLT
FF_I_TYPE -> AV_PICTURE_TYPE_I

这应该涵盖您所有的实际错误。如果只是一个警告,那么请花一些时间来弄清楚他们正在逐步采用什么!

于 2013-07-11T20:52:09.100 回答