Skip to content

Commit 41d5805

Browse files
committed
Only call av_register_all() if libavformat is older than version 58.9.100
This patch adds a preprocessor #define to ensure we only call the deprecated function av_register_all() when working with versions of libavformat older than 58.9.100. The function av_register_all() was removed in ffmpeg 5.0.
1 parent 8e86193 commit 41d5805

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ ENDIF (APPLE)
2626

2727
PKG_CHECK_MODULES(LAVC libavcodec REQUIRED)
2828
PKG_CHECK_MODULES(LAVF libavformat REQUIRED)
29+
IF (${LAVF_VERSION} VERSION_LESS 58.9.100)
30+
add_compile_definitions(LAVF_REGISTER_ALL=1)
31+
ENDIF ()
2932
PKG_CHECK_MODULES(LAVR libswresample REQUIRED)
3033
PKG_CHECK_MODULES(LAVU libavutil REQUIRED)
3134
PKG_CHECK_MODULES(LTAG taglib REQUIRED)

src/scan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ static int scan_nb_files = 0;
6464
#define LUFS_TO_RG(L) (-18 - L)
6565

6666
int scan_init(unsigned nb_files) {
67+
#ifdef LAVF_REGISTER_ALL
6768
/*
6869
* av_register_all() got deprecated in lavf 58.9.100
6970
* It is now useless
7071
* https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
7172
*/
7273
if (avformat_version() < AV_VERSION_INT(58,9,100))
7374
av_register_all();
75+
#endif /* LAVF_REGISTER_ALL */
7476

7577
av_log_set_callback(scan_av_log);
7678

0 commit comments

Comments
 (0)