Import animated GIFs as movies
GIFs went through the still-image path, so an animated GIF came in as a single frame with zero duration. A GIF with two or more frames is now probed as a movie: its frame rate is chosen so every per-frame delay is a whole number of frames (uneven timing is kept exactly), delays of 0 or 1 hundredths count as 10 like in browsers, and the pool decodes the frame shown at the requested time. A single-frame GIF stays a still. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
813c7c4650
commit
bfbdadd34a
@@ -65,6 +65,12 @@ pub fn probe_bytes(path: &str, bytes: Arc<[u8]>) -> Result<Footage> {
|
||||
return probe_model(path, &bytes, &|_| None);
|
||||
}
|
||||
if let Ok(fmt) = image::guess_format(&bytes) {
|
||||
// An animated GIF is a movie; one with a single frame is a still.
|
||||
if fmt == image::ImageFormat::Gif
|
||||
&& let Some(f) = crate::gif_anim::probe(path, &bytes)
|
||||
{
|
||||
return Ok(f);
|
||||
}
|
||||
return probe_still_bytes(path, &bytes, fmt);
|
||||
}
|
||||
let name = Path::new(path).file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| path.to_string());
|
||||
|
||||
Reference in New Issue
Block a user