mux/mp4: route through WritebackFile (bounded-cache writeback)

Make Mp4Sink generic over a seekable writer; the CLI output() arm wraps
the file in WritebackFile (as mkv:// does) so a UHD-scale mux to slow /
NFS staging avoids the dirty-page burst. The mdat backpatch is an
ordinary seek WritebackFile already handles (seek_then_patch_roundtrip).
Tests switched to in-memory Cursor writers.
This commit is contained in:
Matthew Jackson
2026-07-18 20:57:44 -07:00
parent 1e3610fd75
commit 65e14fe3b7
2 changed files with 45 additions and 48 deletions
+9 -1
View File
@@ -555,7 +555,15 @@ pub fn output(
}
StreamUrl::Mp4 { ref path } => {
validate_file_path(path, "mp4")?;
Ok(Box::new(super::mp4::Mp4Sink::create(path, title)?))
// Bounded-cache writeback (like mkv://) so a UHD-scale mux to slow /
// network-attached staging doesn't hit the dirty-page burst
// pathology; the mdat backpatch is an ordinary seek WritebackFile
// handles. BufWriter coalesces the many small moov box-header writes.
let writer = std::io::BufWriter::with_capacity(
IO_BUF_SIZE,
crate::io::WritebackFile::create_with_size_hint(path, title.size_bytes)?,
);
Ok(Box::new(super::mp4::Mp4Sink::create(writer, title)?))
}
StreamUrl::M2ts { ref path } => {
validate_file_path(path, "m2ts")?;