From 3ca155da6853dd6cbaf18e5fb527a15bfa984e23 Mon Sep 17 00:00:00 2001 From: pfeatherstone <45853521+pfeatherstone@users.noreply.github.com> Date: Thu, 1 Aug 2024 13:48:47 +0100 Subject: [PATCH] [FFMPEG] support ffmpeg 7 (#2987) * support ffmpeg 7 * you need assembler --------- Co-authored-by: pfeatherstone --- .github/workflows/build_cpp.yml | 33 +++++++++++++++++++++++++++++++++ dlib/media/ffmpeg_details.h | 6 +++++- dlib/media/ffmpeg_muxer.h | 2 +- dlib/media/ffmpeg_utils.h | 2 +- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_cpp.yml b/.github/workflows/build_cpp.yml index 56e03a984..7a309065b 100644 --- a/.github/workflows/build_cpp.yml +++ b/.github/workflows/build_cpp.yml @@ -195,6 +195,39 @@ jobs: - name: Build examples, etc run: cmake --build build --config Release --parallel 2 + ubuntu-latest-ffmpeg7: + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt update + sudo apt install make yasm + + - name: Cache FFmpeg 7 + uses: actions/cache@v3 + id: cache-ffmpeg7 + with: + path: /home/runner/ffmpeg-n7.0.1_installation + key: ffmpeg-n7.0.1_try2 + + - name: Build FFmpeg 7 + if: steps.cache-ffmpeg7.outputs.cache-hit != 'true' + run: | + wget https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n7.0.1.tar.gz + tar -xf n7.0.1.tar.gz + cd FFmpeg-n7.0.1 + ./configure --prefix=/home/runner/ffmpeg-n7.0.1_installation --disable-doc --disable-programs + make -j4 + make install + cd .. + + - name: Configure + run: cmake . -B build -DCMAKE_PREFIX_PATH=/home/runner/ffmpeg-n7.0.1_installation + - name: Build ffmpeg example + run: cmake --build build --config Release --target ffmpeg_video_muxing_ex --parallel 4 + windows-latest: runs-on: 'windows-latest' steps: diff --git a/dlib/media/ffmpeg_details.h b/dlib/media/ffmpeg_details.h index 801b29e51..a62a55ce7 100644 --- a/dlib/media/ffmpeg_details.h +++ b/dlib/media/ffmpeg_details.h @@ -64,6 +64,10 @@ extern "C" { #include #include "../logger.h" +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 24, 100) +#define FFMPEG_HAS_CH_LAYOUT 1 +#endif + namespace dlib { namespace ffmpeg { namespace details { @@ -156,7 +160,7 @@ namespace dlib { namespace ffmpeg { namespace details } } -#if FF_API_OLD_CHANNEL_LAYOUT +#if FFMPEG_HAS_CH_LAYOUT inline AVChannelLayout convert_layout(const uint64_t channel_layout) { diff --git a/dlib/media/ffmpeg_muxer.h b/dlib/media/ffmpeg_muxer.h index ddf2c2363..75bf6d7de 100644 --- a/dlib/media/ffmpeg_muxer.h +++ b/dlib/media/ffmpeg_muxer.h @@ -788,7 +788,7 @@ namespace dlib } } -#if FF_API_OLD_CHANNEL_LAYOUT +#if FFMPEG_HAS_CH_LAYOUT if (pCodec->ch_layouts) { bool channel_layout_supported = false; diff --git a/dlib/media/ffmpeg_utils.h b/dlib/media/ffmpeg_utils.h index 19fe3da4b..f6487041f 100644 --- a/dlib/media/ffmpeg_utils.h +++ b/dlib/media/ffmpeg_utils.h @@ -775,7 +775,7 @@ namespace dlib if (std::tie(src_sample_rate, src_channel_layout, src_fmt) != std::tie(dst_sample_rate, dst_channel_layout, dst_fmt)) { -#if FF_API_OLD_CHANNEL_LAYOUT +#if LIBSWRESAMPLE_VERSION_INT >= AV_VERSION_INT(4, 5, 100) AVChannelLayout layout_src = convert_layout(src_channel_layout); AVChannelLayout layout_dst = convert_layout(dst_channel_layout);