From 94658cd808516e573289db086f3e65a47cc28dab Mon Sep 17 00:00:00 2001 From: kieran Date: Thu, 21 Nov 2024 10:41:06 +0000 Subject: [PATCH] fix: get_frame_duration --- build.rs | 4 ---- src/lib.rs | 13 +++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index eedefd3..c3327c5 100644 --- a/build.rs +++ b/build.rs @@ -8,10 +8,6 @@ fn main() { let feature_name = name["DEP_FFMPEG_".len()..name.len()].to_lowercase(); println!(r#"cargo::rustc-check-cfg=cfg(feature, values("{feature_name}"))"#); println!(r#"cargo::rustc-cfg=feature="{feature_name}""#); - println!( - r#"cargo::rustc-env=DEP_FFMPEG_{}=1"#, - feature_name.to_uppercase() - ); } } } diff --git a/src/lib.rs b/src/lib.rs index fc81c7c..3899ef5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,6 +62,19 @@ macro_rules! rstr { }; } +/// Version dependant [AVFrame].duration +pub unsafe fn get_frame_duration(frame: *mut AVFrame) -> i64 { + #[cfg(feature = "avutil_version_greater_than_57_30")] + return (*frame).duration; + #[cfg(feature = "avcodec_version_greater_than_54_24")] + return (*frame).pkt_duration; + #[cfg(all( + not(feature = "avcodec_version_greater_than_54_24"), + not(feature = "avutil_version_greater_than_57_30") + ))] + compile_error!("no frame duration support"); +} + #[cfg(target_os = "macos")] type VaList = ffmpeg_sys_the_third::va_list; #[cfg(target_os = "linux")]