use std::path::Path;
use image::DynamicImage;
use super::ffmpeg_decode;
pub fn should_try_ffmpeg_fallback(path: &Path) -> bool {
path.extension()
.and_then(|e| e.to_str())
.is_some_and(|ext| {
matches!(
ext.to_ascii_lowercase().as_str(),
"avif" | "tif" | "tiff"
)
})
}
#[cfg(feature = "video")]
pub fn try_decode_via_ffmpeg(path: &Path) -> Option<DynamicImage> {
if !should_try_ffmpeg_fallback(path) {
return None;
}
ffmpeg_decode::decode_first_frame(path)
}
#[cfg(not(feature = "video"))]
pub fn try_decode_via_ffmpeg(_path: &Path) -> Option<DynamicImage> {
None
}