Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(nvdsdynamicsrcbin): drain decoder per file and avoid stall on switch - #132

Open
nv-support wants to merge 2 commits into
developfrom
fix/128-dynamicsrcbin-file-switch
Open

nv-support wants to merge 2 commits into
developfrom
fix/128-dynamicsrcbin-file-switch

Conversation

@nv-support

@nv-support nv-support commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes #128.

Two changes in gstnvdsdynamicsrcbin.c:

  • At the end of each file, push a still-frame event into the decoder before the custom-eos-event. GstVideoDecoder drains on it without going EOS, so all frames of the file come out before the end marker. The event is dropped at the bin's src pad and does not reach downstream elements.
  • Drop RECONFIGURE events at the parsebin sink pad. Upstream of parsebin is an unparsed byte stream, so there is nothing to renegotiate there.

Event names, fields and bus messages are unchanged; no change is needed in Service Maker, pyservicemaker or the sample.

Reason

Frame loss. The bin replaces the per-file EOS with a custom-eos-event and a GAP before the decoder, so the decoder is never drained. It still holds the file's last frames when the custom-eos-event goes out, and the dynamic-src-bin-file-change message posted from it comes before those frames. MediaExtractor closes the chunk on that message and drops the later frames (22 to 27 of 30 frames per 1 s chunk); the last file's held frames never come out.

Playback stops with no error. For each file the bin builds a new filesrc ! queue ! parsebin. While parsebin links its internal elements and its src pad, each link sends a RECONFIGURE upstream. A 1 s file is read in about 1 ms, so one can arrive just after filesrc pushed its last buffer. filesrc then renegotiates and its ALLOCATION query is queued behind that buffer; the demuxer returns EOS for the buffer, the queue discards the query, and filesrc waits forever (gst_queue_handle_sink_query, gstqueue.c:1119). The file never ends, so the bin never switches.

Validation

Item Value
Platform (x86 GPU / Jetson, GPU or board, OS) Jetson Thor, deepstream:9.2-triton-multiarch container
DeepStream version 9.2.0
Tested commit Same change applied to the installed SDK sources (sources/gst-plugins/gst-nvdynamicsrcbin), plugin rebuilt with make CUDA_VER=13.2
Build result (bash ./build/build.sh --package) Not run
Sanity config (source4) Not run
Test duration About 3 h of stress runs in total
Test result See below
Test Without patch With patch
Issue reproducer, 50 x 1 s chunks, 40 runs 960 to 1,000 of 1,500 frames per run; 2 stops 1,500 of 1,500 every run; no stop
Same, 200 chunks per run, 60 runs about 1 stop every 22 runs 6,000 of 6,000 each; no stop
deepstream_dynamicsrcbin_test, 50 files, 120 runs about 6 frames per file after its end marker; stops 1,500 frames, none after an end marker; no stop
Same, clip remuxed with -movflags +faststart, 120 runs with only the drain change: 9 stops, all on the second file no stop
Unmodified sample, 2 x sample_1080p_h264.mp4 2,883 frames 2,886 frames
2 x sample_1080p_h265.mp4 1,443 + 1,440, 15 to 16 after the end markers 1,443 + 1,443, none after the end markers
remove-source 0.5 s after add-source ends normally ends normally
MediaChunk(duration=0.5 s), 20 chunks 16 frames per chunk 16 frames per chunk
python/tests/test_media.py 10 passed 10 passed

Known limitations:

  • Tested on Jetson Thor only; x86 dGPU is not tested.
  • The per-file drain adds decoder work at every switch; its cost against the unpatched plugin has not been measured under the same conditions.
  • Switching codec between files (H.264 then H.265) stops on the second file with or without this change; not addressed here.

Checklist

  • My working branch is based on NVIDIA/DeepStream:develop.
  • The PR targets NVIDIA/DeepStream:develop.
  • bash ./build/build.sh --package completed successfully.
  • The source4 sanity test passed with the newly built deepstream-app on x86 or Jetson.
  • The PR records the tested platform, software version, commit, source4 configuration, test duration, and results.
  • Additional tests relevant to the change passed, where applicable.
  • My submitted commits include contributor sign-off (git commit -s).
  • Affected documentation and CHANGELOG.md are updated, where applicable.

🤖 Generated with Claude Code

Push a still-frame event into the decoder before the custom-eos-event at
the end of each file. GstVideoDecoder drains on it without going EOS, so
all frames of the file are output before the end marker and the
dynamic-src-bin-file-change message. The event is dropped at the bin's
src pad.

Drop RECONFIGURE events at the parsebin sink pad. When one reaches
filesrc right after its last buffer, filesrc renegotiates and its
ALLOCATION query is queued behind that buffer; the queue discards it when
the demuxer returns EOS, filesrc blocks and the file never ends.

Fixes #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: junshengy <junshengy@nvidia.com>
@nv-support
nv-support force-pushed the fix/128-dynamicsrcbin-file-switch branch from 44d8dfd to fa9d01d Compare November 17, 2026 12:09
@nv-support
nv-support marked this pull request as ready for review November 17, 2026 12:10
Turn the per-file EOS into a custom serialized event at the sink pad of
queue_parsebin and generate the end-of-file events from it.

queue_parsebin is kept for all files. With an EOS, its task pauses once
it has pushed the EOS. The next file can be linked while that push is
still blocked downstream (e.g. in nvinfer, which waits for its queues to
empty); its stream-start clears the EOS state before the task pauses, so
nothing restarts the task and every buffer of the next file gets EOS.
Playback then stops with no error.

Refs #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: junshengy <junshengy@nvidia.com>
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