mux/mp4: MP4 demuxer — mp4:// as a source

Read side of mp4://: parse moov/trak/stbl (stsd codecs+hvcC/avcC/channel
info, stsz/stco/co64+stsc → per-sample offsets, stts+ctts → decode/
composition timing, stss → sync), rebuild a DiscTitle, and emit samples
as PesFrames in global decode order. Video NALs are length-prefixed in
MP4 — the exact framing the MKV muxer wants — so no reframing. Wired into
input() so mp4:// flows to every sink (mkv://, audio://, json://, …).
In-memory write→read round-trip test proves symmetry (streams, hvcC,
sample sizes survive). Progressive MP4 only; fragmented (moof) is future.
This commit is contained in:
Matthew Jackson
2026-07-18 21:10:15 -07:00
parent 65e14fe3b7
commit 8f55cb78d2
3 changed files with 710 additions and 2 deletions
+2
View File
@@ -27,7 +27,9 @@ use std::io::{self, Seek, SeekFrom, Write};
mod audio;
mod boxes;
mod read;
use boxes::{bx, fullbox};
pub use read::Mp4Reader;
/// Nanoseconds per second — PTS is carried in ns, media timescales are Hz.
const NS: i64 = 1_000_000_000;