fix: get_frame_duration

This commit is contained in:
kieran 2024-11-21 10:41:06 +00:00
parent d783291f74
commit 94658cd808
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
2 changed files with 13 additions and 4 deletions

View File

@ -8,10 +8,6 @@ fn main() {
let feature_name = name["DEP_FFMPEG_".len()..name.len()].to_lowercase(); 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-check-cfg=cfg(feature, values("{feature_name}"))"#);
println!(r#"cargo::rustc-cfg=feature="{feature_name}""#); println!(r#"cargo::rustc-cfg=feature="{feature_name}""#);
println!(
r#"cargo::rustc-env=DEP_FFMPEG_{}=1"#,
feature_name.to_uppercase()
);
} }
} }
} }

View File

@ -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")] #[cfg(target_os = "macos")]
type VaList = ffmpeg_sys_the_third::va_list; type VaList = ffmpeg_sys_the_third::va_list;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]