ReviewOS

also looking at this

home-lang/home

feat(video): add native AVC/HEVC and synchronized AAC MP4 streaming

#913
Merged chris wants to merge feat/avc-hevc-mp4 into main
14 files +1119 -0
packages/video/docs/native-video.mdadded+25-0
Changes to packages/video/docs/native-video.md
@@ -0,0 +1,25 @@
1# Header-checked native video adapter
2
3`codecs/video/native_encoder.{c,h,zig}` compiles the x264/x265 boundary against
4installed vendor headers. Only Home-owned scalar configuration and borrowed
5length-prefixed packet data cross the interface. The Zig wrapper validates input
6geometry, timestamps and encode/drain state. Link the C source and libx264/libx265.
7
8`Encoder.requestKeyframe()` / `home_encoder_request_keyframe` requests an IDR for
9the next submitted input. Requests coalesce. This supports independently decodable
10recording splits without waiting for the regular GOP interval. Inspect emitted
11packet timestamps and key flags before switching outputs: buffered AVC output
12can precede the newly requested IDR. Keep headers outside packet history and
13remux each segment with a fresh sample description and a rebased timeline.
14
15Use requests only on an active encoder before draining, serialize every operation,
16and consume borrowed output before another adapter call. The Zig wrapper rejects
17requests after drain/failure. A request neither drains nor resets the encoder.
18
19The standalone `tests/native_encoder_idr.zig` imports this module as `encoder` and
20links its compiled C boundary. Its regression encodes eight frames under GOP100,
21forces IDRs at inputs 3 and 6, checks actual AVC/HEVC IDR NAL types and packet keys,
22counts every delayed/flushed frame, and rejects requests after drain. It passes
23on Zig 0.15.2 and Home's installed 0.17 development toolchain with x264/x265.
24zig-camera additionally remuxes split files and pre-roll snapshots and validates
25them with independent decoders. No FFmpeg or Libav is used in this path.