Skip to content

fix(nodes): repeat H.264 SPS/PPS before every IDR on RTSP inputs - #1357

Open
justin-guth-sima wants to merge 1 commit into
developfrom
fix/h264-rtsp-parameter-sets
Open

justin-guth-sima wants to merge 1 commit into
developfrom
fix/h264-rtsp-parameter-sets

Conversation

@justin-guth-sima

Copy link
Copy Markdown

Summary

H264Depacketize wrote h264parse's config-interval only for values >= 0 and treated -1
as "leave the element default" (0, never repeat). So no RTSP H.264 input repeated parameter sets,
and an app could not ask for GStreamer's -1, "before every IDR".

In a fused encoded branch this loses a stream's video for the whole run: sources republished
without re-encoding carry SPS/PPS only ahead of the first access unit, the leaky egress queue
(RealtimeLatestByStream) sometimes drops that access unit at startup, and the egress h264parse
then drops every frame. With 16 RTSP streams in high-density-multi-stream-object-detector, 1 to 4
random streams sent no video in every run. Details and logs are in the issue.

config-interval is now always written, -1 by default, as H265Depacketize already does. 0
still turns repetition off, N > 0 repeats every N seconds, and values below -1 (which
h264parse would reject when the pipeline is parsed) throw std::invalid_argument from
backend_fragment, as partial caps already do.

Fixes #1356

Change Type

  • Bug fix
  • Refactor
  • Feature
  • Docs
  • Test-only
  • Build/CI
  • Breaking change

Risk

  • Low
  • Medium
  • High

Risk notes (required for Medium/High): every RTSP H.264 input (RtspEncodedInput,
RtspDecodedInput, direct H264Depacketize users) now repeats SPS/PPS before each IDR unless the
app sets the interval. The parser inserts them only where an IDR lacks them, so streams that
already carry them are unchanged; others gain a few dozen bytes per IDR. The decoder receives the
parameter sets it already had. An app that relied on -1 meaning "never repeat" gets that with
0.

Test Evidence

Commands run and outcomes:

- tests/unit_testing/unit_nodes_test.cpp: new checks that the default fragment carries
  config-interval=-1, that 0 is kept, and that -2 throws. Not run locally: the unit tests need the
  Core build with its Scheduler set; left to CI on this branch.
- Host check of the changed source (g++ -std=c++20, H264Depacketize.cpp alone): fragments for -1,
  0 and 1 as expected, -2 throws "H264Depacketize: h264_parse_config_interval must be -1 (every
  IDR), 0 (off) or a positive interval in seconds".
- clang-format --dry-run --Werror on the changed files: clean.
- DevKit, GStreamer reproduction of the fused branch (egress closed for its first 5 s):
  parser as before 0 packets in 15 s; with config-interval=-1 20,925 packets.
- DevKit, the app's Python version with 16 streams (16 video ports checked 40 s after start):
  h264_parse_config_interval unset: a stream without video in 4 of 4 runs;
  set to 1 (what the option can express before this change): 0 of 4 runs.
  The patched library itself was not run on the DevKit (no local Core build).

Docs Impact

  • No docs update needed
  • Docs updated in this PR
  • Docs follow-up required (linked issue)

Docs notes: the option's doc comments in RtspEncodedInput.h, RtspDecodedInput.h and
H264Depacketize.h now say what -1, 0 and N > 0 do.

Migration Impact

  • No migration impact
  • Migration required and documented

Migration notes (required if impact exists):

Breaking API Change

  • Not applicable
  • This PR changes public API signatures under include/*

API / Deprecation Checklist

  • Public API unchanged
  • Public API changed with deprecation path documented in docs/how-to
  • Naming contract respected (docs/architecture/naming.md)

Release Hygiene Checklist

  • scripts/ci/check_naming_and_conflicts.sh passed
  • scripts/ci/check_artifacts.sh passed
  • scripts/ci/check_release_policy.sh passed

H264Depacketize wrote h264parse's config-interval only for values >= 0 and
treated -1 as "leave the element default" (0, never repeat). An app could
therefore not ask for -1, GStreamer's "before every IDR", and the RTSP inputs
never repeated parameter sets.

Sources republished without re-encoding (MP4 over RTSP) carry SPS/PPS in-band
only ahead of the first access unit. In a fused encoded branch the egress
queue is leaky (RealtimeLatestByStream); when it drops that first access unit
at startup, the egress h264parse never sees SPS/PPS and drops every frame for
the rest of the run, while the lossless decode branch keeps working. With 16
RTSP streams this left 1-4 random channels without video in every run.

config-interval is now always written, -1 by default, as H265Depacketize
already does. 0 still turns repetition off and N > 0 repeats every N seconds;
values below -1 are rejected.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T07:52:32.595590Z b6a0e33 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch was successfully deployed

2 active deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant