Repository navigation
Skipping MP4 fragments for packs that carry only parameter sets - #98
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Summary by QodoSkip MP4 fragments for packs without video slices
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Some HEVC frames vanish from MP4 output
|
|
Reply to the automatic review. No change to the branch; both points are gaps that exist without this change too.
🤖 Generated with Claude Code |
What was wrong
On HALs that deliver SPS, PPS (and VPS) in packs of their own, the fragmented MP4 output (
/video.mp4and the recorder) writes the previous frame again for each such pack, with its audio. Seen on a Ruision F8 board (FH8856V200), which delivers a key frame as separate SPS, PPS and slice packs: a 60 s/video.mp4capture at 25 fps had 1560 video frames instead of 1500, and the repeated audio showed as gaps and jumps.Why
send_mp4_to_client()(src/server.c) andrecord_ingest_stream()(src/record.c) loop over the packs of a stream. For each pack they feed its NAL units to the muxer and then always emit a fragment. A slice NAL (mp4_set_slice()) is what fills the fragment; SPS and PPS only update the stored parameter sets. For a pack with no slice, the fragment buffers still hold the previous frame (and the audio queued with it), which is then sent or written a second time.What this changes
send_mp4_to_client(): note whether the pack had a slice and skip the fragment if it did not.record_feed_nalu()returns whether it fed a slice;record_ingest_stream()skips the fragment for packs without one.Packs that carry parameter sets together with a slice (the usual case on other HALs) are not affected.
How it was checked
./build.sh fhan-v2, no new warnings;./test.sh -apasses./video.mp4capture had 1500 frames, all 40 ms apart, and no audio gaps; recordings likewise. Before, 1560 frames in 60 s.Effect on other platforms
Shared code. Only packs without a slice change behaviour (no fragment instead of a repeated one). If a HAL puts a slice and parameter sets in one pack, nothing changes.
🤖 Generated with Claude Code