nx_mp4_faststart.nx
buildroot/runtime/nx_mp4_faststart.nx
about
nx_mp4_faststart.nx -- qt-faststart: relocate the moov atom to the FRONT of an mp4 so a browser <video>
can stream it progressively over HTTP. A non-faststart mp4 has [ftyp][mdat...][moov] (moov at the END), so
the player's first Range read has ftyp+mdat but NO moov (the track/sample tables) -> "no video, this format
is not supported". Moving moov before mdat fixes it. LOSSLESS: no transcode; the ONLY mutation is rewriting
each stco (32-bit) / co64 (64-bit) chunk offset by +moov_size, because inserting moov after ftyp shifts every
byte of mdat forward by exactly moov_size. Reads argv[1] (the mp4), writes the faststart mp4 to stdout (fd 1).
If the file is ALREADY faststart (moov before mdat) or has no moov, it is copied verbatim (safe no-op).
license_tier: ORIGINAL No hw writes (Rule 26). module: nishi-core.torrent.mp4_faststart
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 11 | const FS_RD: i64 = 262144 |
functions
| 13 | func fs_be32(b: *u8, o: i64) -> i64 { return ((b[o] as i64)<<24)|((b[o+1] as i64)<<16)|((b[o+2] as i64)<<8)|(b[o+3] as i64) } |
| 14 | func fs_be64(b: *u8, o: i64) -> i64 { var v: i64=0; var i: i64=0; while i<8 { v=(v<<8)|(b[o+i] as i64); i=i+1 } return v } |
| 15 | func fs_put32(b: *u8, o: i64, v: i64) -> i64 { b[o]=((v>>24)&0xff) as u8; b[o+1]=((v>>16)&0xff) as u8; b[o+2]=((v>>8)&0xff) as u8; b[o+3]=(v&0xff) as u8; return 0 } called by 1: fs_adjust |
| 16 | func fs_put64(b: *u8, o: i64, v: i64) -> i64 { var i: i64=0; while i<8 { b[o+7-i]=((v>>(i*8))&0xff) as u8; i=i+1 } return 0 } called by 1: fs_adjust |
| 17 | func fs_teq(b: *u8, o: i64, t: *u8) -> i64 { var i: i64=0; while i<4 { if b[o+i]!=t[i] { return 0 } i=i+1 } return 1 } |
| 18 | func fs_iscont(b: *u8, o: i64) -> i64 |
| 26 | func fs_adjust(m: *u8, start: i64, end: i64, shift: i64) -> i64 |
| 51 | func fs_emit(fd: i64, start: i64, len: i64, buf: *u8) -> i64 |
| 57 | func main(argc: i64, argv: *i64) -> i64 |