From 13a4716b6582dd0c56ecf2de165974825d0364b3 Mon Sep 17 00:00:00 2001 From: Donough Liu Date: Tue, 2 Jan 2024 01:25:29 +0800 Subject: [PATCH] Remove FFmpeg 4 and 5 support (#131) --- .github/workflows/ci.yml | 18 ++++++------------ Cargo.toml | 4 ---- README.md | 6 +----- src/avcodec/bitstream.rs | 3 --- src/avutil/dict.rs | 4 ---- src/avutil/frame.rs | 8 +------- tests/metadata.rs | 1 - 7 files changed, 8 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fa402c..14d3383 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: - run: | export FFMPEG_PKG_CONFIG_PATH=${PWD}/tmp/ffmpeg_build/lib/pkgconfig - cargo clippy --features ffmpeg6 -vv -- -D warnings + cargo clippy -vv -- -D warnings rust_clippy_check_windows: runs-on: windows-latest @@ -99,28 +99,22 @@ jobs: VCPKG_ROOT: ${{ github.workspace }}/vcpkg LIBCLANG_PATH: ${{ github.workspace }}/clang/lib LLVM_CONFIG_PATH: ${{ github.workspace }}/clang/bin/llvm-config - run: cargo clippy --features ffmpeg6 -- -D warnings + run: cargo clippy -- -D warnings build_static_and_test_ubuntu: runs-on: ubuntu-latest strategy: matrix: - ffmpeg-version: ["release/4.3", "release/5.0", "release/6.1"] + ffmpeg-version: ["release/6.0", "release/6.1"] rust: ["nightly", "1.70.0"] valgrind: ["valgrind", "no valgrind"] include: - - ffmpeg-version: "release/5.0" - cargo-features: --features ffmpeg5 - - ffmpeg-version: "release/6.1" - cargo-features: --features ffmpeg6 - rust: "nightly" should_test: "true" exclude: # Only run valgrind with latest FFmpeg and nightly rust to reduce resource consumption. - valgrind: "valgrind" - ffmpeg-version: "release/5.0" - - valgrind: "valgrind" - ffmpeg-version: "release/4.3" + ffmpeg-version: "release/6.0" - valgrind: "valgrind" rust: "1.70.0" fail-fast: false @@ -284,7 +278,7 @@ jobs: LLVM_CONFIG_PATH: ${{ github.workspace }}/clang/bin/llvm-config run: | copy ${{ github.workspace }}/ffmpeg_prebuilt_cross/lib/libffmpeg.dll . - cargo test --tests --features ffmpeg6 --target i686-pc-windows-msvc -vv -- --skip transcoding + cargo test --tests --target i686-pc-windows-msvc -vv -- --skip transcoding # Check if correct documentation can be generated by docs.rs docs_rs_check: @@ -312,4 +306,4 @@ jobs: - name: Set env run: echo "DOCS_RS=1" >> $GITHUB_ENV - name: Document Generation - run: cargo doc --features ffmpeg6 -vv + run: cargo doc -vv diff --git a/Cargo.toml b/Cargo.toml index 374010b..7c4b80a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,9 +26,5 @@ once_cell = "1.12.0" tempdir = "0.3.7" [features] -# FFmpeg 5.* support -ffmpeg5 = ["rusty_ffmpeg/ffmpeg5"] -# FFmpeg 6.* support -ffmpeg6 = ["rusty_ffmpeg/ffmpeg6"] # linking system ffmpeg as fallback. link_system_ffmpeg = ["rusty_ffmpeg/link_system_ffmpeg"] diff --git a/README.md b/README.md index 976dac2..5041dde 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,7 @@ Taking advantage of Rust's language design, you can build robust multi-media pro ## Dependency requirements -Supported FFmpeg versions are: -- `4.3` -- `4.4` -- `5.*`(Enabled by feature `ffmpeg5`) -- `6.*`(Enabled by feature `ffmpeg6`). +Supported FFmpeg versions are `6.*`. Minimum Supported Rust Version is 1.70.0(Stable channel). diff --git a/src/avcodec/bitstream.rs b/src/avcodec/bitstream.rs index 8618aaa..6519566 100644 --- a/src/avcodec/bitstream.rs +++ b/src/avcodec/bitstream.rs @@ -231,10 +231,7 @@ mod test { #[test] fn test_null_filter() { let ctx = AVBSFContextUninit::get_null(); - #[cfg(any(feature = "ffmpeg5", feature = "ffmpeg6"))] assert_eq!(cstr!("null"), ctx.filter().name()); - #[cfg(not(any(feature = "ffmpeg5", feature = "ffmpeg6")))] - assert_eq!(cstr!("bsf_list"), ctx.filter().name()); } #[test] diff --git a/src/avutil/dict.rs b/src/avutil/dict.rs index 4990114..ee33b05 100644 --- a/src/avutil/dict.rs +++ b/src/avutil/dict.rs @@ -157,7 +157,6 @@ impl<'dict> AVDictionary { } /// Iterates through all entries in the dictionary by reference. - #[cfg(feature = "ffmpeg6")] pub fn iter(&'dict self) -> AVDictionaryIter<'dict> { AVDictionaryIter { dict: self, @@ -185,7 +184,6 @@ impl Drop for AVDictionary { } } -#[cfg(feature = "ffmpeg6")] impl<'dict> IntoIterator for &'dict AVDictionary { type IntoIter = AVDictionaryIter<'dict>; type Item = AVDictionaryEntryRef<'dict>; @@ -195,14 +193,12 @@ impl<'dict> IntoIterator for &'dict AVDictionary { } /// Iterator over [`AVDictionary`] by reference. -#[cfg(feature = "ffmpeg6")] pub struct AVDictionaryIter<'dict> { dict: &'dict AVDictionary, ptr: *const ffi::AVDictionaryEntry, _phantom: std::marker::PhantomData<&'dict ()>, } -#[cfg(feature = "ffmpeg6")] impl<'dict> Iterator for AVDictionaryIter<'dict> { type Item = AVDictionaryEntryRef<'dict>; fn next(&mut self) -> Option { diff --git a/src/avutil/frame.rs b/src/avutil/frame.rs index 181f052..db6b9c0 100644 --- a/src/avutil/frame.rs +++ b/src/avutil/frame.rs @@ -226,16 +226,10 @@ wrap_ref!(AVFrameSideData: ffi::AVFrameSideData); impl<'frame> AVFrameSideDataRef<'frame> { unsafe fn as_motion_vectors(&self) -> &'frame [AVMotionVector] { - // FFmpeg 4 defines `AVFrameSideData::size` as `int` - // ref: https://github.com/CCExtractor/rusty_ffmpeg/issues/93 - #[cfg(not(any(feature = "ffmpeg5", feature = "ffmpeg6")))] - let size = self.size as usize; - #[cfg(any(feature = "ffmpeg5", feature = "ffmpeg6"))] - let size = self.size; unsafe { slice::from_raw_parts( self.data as *const _ as *const ffi::AVMotionVector, - size / size_of::(), + self.size / size_of::(), ) } } diff --git a/tests/metadata.rs b/tests/metadata.rs index 67250a5..5f1c777 100644 --- a/tests/metadata.rs +++ b/tests/metadata.rs @@ -1,4 +1,3 @@ -#![cfg(feature = "ffmpeg6")] use anyhow::{Context, Result}; use rsmpeg::{avcodec::AVCodecContext, avformat::AVFormatContextInput, avutil::av_q2d, ffi}; use std::ffi::CString;