#794: open movies in place instead of reading them whole
Problem: probe() and MediaPool's movie sources called std::fs::read and then filmcraft_codecs::open_bytes, so a clip cost its full size in memory, twice while probing (a 245 MiB MP4 peaked at 494 MiB just to import). Fix: container footage on disk is opened through a positional-read ByteReader (stream::FileReader) and FilmCraft's reader openers (filmcraft_media::reader::open_reader; MP4/MOV, Matroska/WebM, MXF, Ogg, MPEG-PS/TS), which read the index and then single samples. Probing takes this path only when nothing probed before containers (still/model extensions, PSD/SVG/PDF, image magic) claims the file; everything else, whole-file audio formats, in-memory files (add_bytes) and wasm32 builds keep the byte path. Regression test: probing and decoding a frame and audio of a movie with a 256 MiB tail grows peak RSS by <64 MiB (512 MiB before), same results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9a7d3e7699
commit
d648026ffd
@@ -40,6 +40,12 @@ fn is_pdf_like(path: &str, bytes: &[u8]) -> bool {
|
||||
effectcraft_pdf::sniff(bytes).is_some() && (effectcraft_pdf::EXTENSIONS.contains(&ext.as_str()) || bytes.starts_with(b"%PDF"))
|
||||
}
|
||||
|
||||
/// Whether `bytes` (the first 64 KiB suffice) are a Photoshop or vector file [`probe`] handles.
|
||||
#[cfg_attr(not(any(unix, windows)), allow(dead_code))]
|
||||
pub(crate) fn sniff(path: &str, bytes: &[u8]) -> bool {
|
||||
effectcraft_psd::is_psd(bytes) || is_svg(path, bytes) || is_pdf_like(path, bytes)
|
||||
}
|
||||
|
||||
/// Footage for a Photoshop or vector file (`None` for other formats).
|
||||
pub(crate) fn probe(path: &str, bytes: &[u8]) -> Result<Option<Footage>> {
|
||||
if effectcraft_psd::is_psd(bytes) {
|
||||
|
||||
Reference in New Issue
Block a user