Skip to content

Commit

Permalink
Only call av_register_all() if libavformat is older than version 58.9…
Browse files Browse the repository at this point in the history
….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.
  • Loading branch information
hughmcmaster committed Feb 13, 2022
1 parent 8e86193 commit 41d5805
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ ENDIF (APPLE)

PKG_CHECK_MODULES(LAVC libavcodec REQUIRED)
PKG_CHECK_MODULES(LAVF libavformat REQUIRED)
IF (${LAVF_VERSION} VERSION_LESS 58.9.100)
add_compile_definitions(LAVF_REGISTER_ALL=1)
ENDIF ()
PKG_CHECK_MODULES(LAVR libswresample REQUIRED)
PKG_CHECK_MODULES(LAVU libavutil REQUIRED)
PKG_CHECK_MODULES(LTAG taglib REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions src/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ static int scan_nb_files = 0;
#define LUFS_TO_RG(L) (-18 - L)

int scan_init(unsigned nb_files) {
#ifdef LAVF_REGISTER_ALL
/*
* av_register_all() got deprecated in lavf 58.9.100
* It is now useless
* https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
*/
if (avformat_version() < AV_VERSION_INT(58,9,100))
av_register_all();
#endif /* LAVF_REGISTER_ALL */

av_log_set_callback(scan_av_log);

Expand Down

0 comments on commit 41d5805

Please sign in to comment.