Repository navigation
Description
Describe the bug
nvmultiurisrcbin with live-source=0 loses the last frames of file:// sources that are added through its REST API while other files play. The frames are already missing at the element's own src pad, so nothing downstream drops them. The element still posts the removed message (DynamicSourceMessage with source_added=False) for every file, so the application sees a normal end.
With 4 files in flight (a new file added as soon as one ends), 200 adds of a 30-frame clip gave 5,802, 5,818 and 5,831 of 6,000 frames in three runs. The short files miss their highest frame numbers: most miss frames 27 to 29, some only frame 29.
The same 200 adds one at a time (one slot, a 0.5 s pause after each end) gave 6,000 of 6,000 frames in three runs.
Steps/Code to reproduce bug
Make a 1 s clip (30 frames) from the image's sample stream. The image has no ffmpeg, so this runs on the host:
docker run --rm --entrypoint cat ghcr.io/nvidia/deepstream:9.2-triton-multiarch \
/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 > sample_720p.mp4
ffmpeg -v error -i sample_720p.mp4 -frames:v 30 -an -c:v libx264 -g 30 clip_1s.mp4Save as repro_tail_frames.py. The pipeline is nvmultiurisrcbin (no sources at start) and fakesink, with a frame counter on the src pad of nvmultiurisrcbin. No inference. Usage: repro_tail_frames.py <clip> <frames in the clip> <files> <files in flight> [pause after each end, s].
import json
import os
import sys
import threading
import time
import urllib.error
import urllib.request
from collections import defaultdict
from pyservicemaker import BatchMetadataOperator, DynamicSourceMessage, Pipeline, Probe
PORT = 9600
OPENER = urllib.request.build_opener(urllib.request.ProxyHandler({}))
lock = threading.Lock()
frames = 0
# Per camera: the frame numbers seen for its source id until the next file's added message for that id.
per_camera = defaultdict(list)
owner = {} # source id -> the camera id of its latest added message
ended = [] # camera ids in the order of their removed messages
class Count(BatchMetadataOperator):
def handle_metadata(self, batch_meta):
global frames
with lock:
for frame in batch_meta.frame_items:
frames += 1
camera = owner.get(int(frame.source_id))
if camera is not None:
per_camera[camera].append(int(frame.frame_number))
def on_message(message):
if isinstance(message, DynamicSourceMessage):
with lock:
if message.source_added:
owner[int(message.source_id)] = str(message.sensor_id)
else:
ended.append(str(message.sensor_id))
def post(verb, camera, path):
value = {"camera_id": camera, "camera_name": camera, "camera_url": f"file://{path}", "change": f"camera_{verb}"}
body = json.dumps({"key": "sensor", "value": value}).encode()
request = urllib.request.Request(f"http://127.0.0.1:{PORT}/api/v1/stream/{verb}", data=body, method="POST")
for _ in range(80): # the REST server needs a moment after start
try:
with OPENER.open(request, timeout=30) as response:
return response.status
except urllib.error.HTTPError as error:
if error.code != 404:
return error.code
except urllib.error.URLError:
pass
time.sleep(0.25)
raise RuntimeError("REST server not up")
clip, clip_frames, total, slots = sys.argv[1], int(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4])
pause = float(sys.argv[5]) if len(sys.argv) > 5 else 0.0
pipeline = Pipeline("tail-frames")
pipeline.add("nvmultiurisrcbin", "src", {
"ip-address": "127.0.0.1", "port": str(PORT), "max-batch-size": slots, "width": 1280, "height": 720,
"live-source": False, "drop-pipeline-eos": True, "batched-push-timeout": 33333,
})
pipeline.add("fakesink", "sink", {"sync": False})
pipeline.link("src", "sink")
pipeline.attach("src", Probe("count", Count()))
pipeline.start(on_message)
threading.Thread(target=pipeline.wait, daemon=True).start()
started = time.monotonic()
added = 0
deadline = time.monotonic() + 600
while time.monotonic() < deadline:
with lock:
done = len(ended)
if done == total:
break
if added < total and added - done < slots:
if pause and done and added == done:
time.sleep(pause)
status = post("add", f"f{added:04d}", clip)
if status != 200:
print(f"add f{added:04d} answered {status}", flush=True)
added += 1
continue
time.sleep(0.005)
elapsed = time.monotonic() - started
time.sleep(2) # frames that reach the pad after the last removed message
with lock:
short = {camera: numbers for camera, numbers in per_camera.items() if len(numbers) < clip_frames}
extra = [camera for camera, numbers in per_camera.items() if len(numbers) > clip_frames]
print(f"files added: {added}, removed messages: {len(ended)}, time: {elapsed:.1f} s")
print(f"frames at the src pad: {frames} of {total * clip_frames} expected ({total * clip_frames - frames} missing)")
print(f"files with fewer than {clip_frames} frames: {len(short)} (counted until the next added message for its source id)")
print(f"files with more than {clip_frames} frames: {len(extra)}")
for camera, numbers in sorted(short.items())[:10]:
missing = sorted(set(range(clip_frames)) - set(numbers))
print(f" {camera}: {len(numbers)} frames, missing frame numbers {missing}")
sys.stdout.flush()
os._exit(0) # the pipeline never ends by itself (drop-pipeline-eos), so leave at onceRun it in the stock container (pyyaml is installed first because import pyservicemaker needs it, see #98):
# 200 files, 4 in flight
docker run --rm --gpus all -v "$PWD":/repro --entrypoint bash ghcr.io/nvidia/deepstream:9.2-triton-multiarch \
-c "pip install -q --break-system-packages pyyaml && python3 /repro/repro_tail_frames.py /repro/clip_1s.mp4 30 200 4"
# control: 200 files, one at a time, 0.5 s pause after each end
docker run --rm --gpus all -v "$PWD":/repro --entrypoint bash ghcr.io/nvidia/deepstream:9.2-triton-multiarch \
-c "pip install -q --break-system-packages pyyaml && python3 /repro/repro_tail_frames.py /repro/clip_1s.mp4 30 200 1 0.5"4 in flight prints (first run):
files added: 200, removed messages: 200, time: 11.6 s
frames at the src pad: 5802 of 6000 expected (198 missing)
files with fewer than 30 frames: 114 (counted until the next added message for its source id)
files with more than 30 frames: 21
f0001: 27 frames, missing frame numbers [27, 28, 29]
f0002: 27 frames, missing frame numbers [27, 28, 29]
f0003: 29 frames, missing frame numbers [29]
f0006: 29 frames, missing frame numbers [29]
f0007: 27 frames, missing frame numbers [27, 28, 29]
f0008: 29 frames, missing frame numbers [29]
f0009: 27 frames, missing frame numbers [27, 28, 29]
f0011: 28 frames, missing frame numbers [28, 29]
f0013: 28 frames, missing frame numbers [28, 29]
f0017: 28 frames, missing frame numbers [27, 29]
The control prints:
files added: 200, removed messages: 200, time: 120.2 s
frames at the src pad: 6000 of 6000 expected (0 missing)
files with fewer than 30 frames: 0 (counted until the next added message for its source id)
files with more than 30 frames: 0
| run | frames at the src pad, 4 in flight | control (one at a time) |
|---|---|---|
| 1 | 5,802 / 6,000 | 6,000 / 6,000 |
| 2 | 5,818 / 6,000 | 6,000 / 6,000 |
| 3 | 5,831 / 6,000 | 6,000 / 6,000 |
The total at the src pad is exact. The per-file counts are approximate: a frame that reaches the pad after the next file's added message for the same source id is counted for that next file, which is why some files show more than 30. stderr has no ERROR line in these runs, only No Sources found at the input of muxer warnings when no file is in flight.
Expected behavior
Every frame of every file reaches the src pad of nvmultiurisrcbin before the element posts the file's removed message: 6,000 of 6,000 frames with 4 files in flight, as with one file at a time.
Environment details
- Environment location: Docker on bare-metal (Ubuntu 26.04.1 LTS host, kernel 7.0.0-43, NVIDIA RTX A4000 Laptop GPU 8 GB, driver 615.71.09)
- Method of DeepStream install: Docker,
ghcr.io/nvidia/deepstream:9.2-triton-multiarch(digestsha256:94a49674eb475f0416ce49742430cfbd644258b4e6512b09c76ddd90164c6dc7), DeepStream 9.2.0, pyservicemaker 0.0.1, TensorRT 10.16.0.72, CUDA 13.2 - Docker command: see the steps above
scripts/print_env.shoutput, run inside the same container:
Click here to see environment details
**git*** Not inside a git repository ***OS Information*** DISTRIB_ID=Ubuntu DISTRIB_RELEASE=24.04 DISTRIB_CODENAME=noble DISTRIB_DESCRIPTION="Ubuntu 24.04.4 LTS" PRETTY_NAME="Ubuntu 24.04.4 LTS" NAME="Ubuntu" VERSION_ID="24.04" VERSION="24.04.4 LTS (Noble Numbat)" VERSION_CODENAME=noble ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=noble LOGO=ubuntu-logo Linux 9616c69d590b 7.0.0-43-generic #43-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 23 13:25:25 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux ***GPU Information*** Mon Nov 16 13:48:45 2026 +-----------------------------------------------------------------------------------------+ | NVIDIA-SMI 615.71.09 KMD Version: 615.71.09 CUDA UMD Version: 13.4 | +-----------------------------------------+------------------------+----------------------+ | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+========================+======================| | 0 NVIDIA RTX A4000 Laptop GPU Off | 00000000:01:00.0 Off | N/A | | N/A 54C P8 16W / 80W | 13MiB / 8192MiB | 0% Default | | | | N/A | +-----------------------------------------+------------------------+----------------------+ +-----------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=========================================================================================| | No running processes found | +-----------------------------------------------------------------------------------------+ ***CPU*** Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 16 On-line CPU(s) list: 0-15 Vendor ID: GenuineIntel Model name: 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz CPU family: 6 Model: 141 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 Stepping: 1 CPU(s) scaling MHz: 38% CPU max MHz: 5000.0000 CPU min MHz: 800.0000 BogoMIPS: 5222.40 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear ibt flush_l1d arch_capabilities Virtualization: VT-x L1d cache: 384 KiB (8 instances) L1i cache: 256 KiB (8 instances) L2 cache: 10 MiB (8 instances) L3 cache: 24 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-15 Vulnerability Gather data sampling: Vulnerable Vulnerability Ghostwrite: Not affected Vulnerability Indirect target selection: Mitigation; Aligned branch/return thunks Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Old microcode: Not affected Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop Vulnerability Srbds: Not affected Vulnerability Tsa: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Not affected ***CMake*** /usr/bin/cmake cmake version 3.28.3 CMake suite maintained and supported by Kitware (kitware.com/cmake). ***g++*** /usr/bin/g++ g++ (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ***nvcc*** /usr/local/cuda/bin/nvcc nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2026 NVIDIA Corporation Built on Mon_Mar_02_09:52:23_PM_PST_2026 Cuda compilation tools, release 13.2, V13.2.51 Build cuda_13.2.r13.2/compiler.37434383_0 ***Python*** ***Environment Variables*** PATH : /opt/proto/bin:/opt/tritonserver/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/mpi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ucx/bin:/opt/amazon/efa/bin:/.local/bin LD_LIBRARY_PATH : /opt/tritonserver/lib:/opt/tritonclient/lib:/usr/src/tensorrt/lib:/opt/riva/lib:/usr/local/cuda-13/lib64:/usr/lib/x86_64-linux-gnu:/opt/hpcx/ucc/lib/:/opt/hpcx/ucx/lib/:/usr/local/cuda/compat/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/.local/lib NUMBAPRO_NVVM : NUMBAPRO_LIBDEVICE : CONDA_PREFIX : PYTHON_PATH : conda not found ***pip packages*** /usr/bin/pip Package Version ------------------- --------------- annotated-doc 0.0.4 annotated-types 0.7.0 anyio 4.12.1 apparmor 4.0.1 certifi 2026.2.25 cupy-cuda13x 13.6.0 distlib 0.4.0 distro 1.9.0 fastapi 0.143.3 fastrlock 0.8.3 filelock 3.25.2 h11 0.16.0 httpcore 1.0.9 httpx 0.27.2 idna 3.11 iniconfig 2.3.0 jaraco.context 6.1.0 jiter 0.13.0 LibAppArmor 4.0.1 numpy 1.26.4 openai 1.107.3 opentelemetry-api 1.45.1 packaging 24.0 partial-json-parser 0.2.1.1.post7 pip 24.0 platformdirs 4.9.4 pluggy 1.6.0 pydantic 2.10.6 pydantic_core 2.27.2 Pygments 2.19.2 pyservicemaker 0.0.1 pytest 9.0.2 python-apt 2.7.7+ubuntu5.3 python-discovery 1.1.3 scipy 1.16.3 setuptools 78.1.1 sniffio 1.3.1 starlette 0.52.1 tqdm 4.67.3 tritonfrontend 2.67.0 tritonserver 0.0.0 typing_extensions 4.15.0 typing-inspection 0.4.4 virtualenv 21.2.0 wheel 0.42.0
Additional context
The loss makes the removed message unusable as "this file is fully processed": an application that adds files at run time and reports per-file results cannot tell a short file from a complete one.
Activity
nvqiezi commentedon Nov 17, 2026
This issue can be reproduced on dGPU with DS9.2. we are investigating.
nvqiezi commentedon Nov 18, 2026
Thanks for the reporting! the issue is in nvstreammux. Since nvstreammux is opensource, you can apply this patch to fix the issue.
workaround.diff.txt
sergeykad commentedon Nov 18, 2026
Thank you for the patch. We built
libnvdsgst_multistream.sofrom the 9.2 sources with it and ran the script of this issue (200 adds of the 30-frame clip, 4 files in flight).The frame count is fixed: 9 of 9 runs gave 6,000 of 6,000 frames at the src pad. The unpatched library gave 5,809 to 5,853 in 7 runs. One file at a time with the patch also gave 6,000 of 6,000.
One thing remains. The last frames of a file can reach the src pad after the element has posted the removed message for that file, and after the next file was added on the same source id. In each patched run 28 to 42 of the 200 files showed fewer than 30 frames before the next added message for their source id, and about as many showed more than 30. An application that takes the removed message as the end of a file's frames attributes those frames to the next file. Is there a supported way to know that the last frame of a removed source has left the element?
nvqiezi commentedon Nov 20, 2026
pyservicemaker does not expose this today. Its probes are buffer-only and its bus watch maps only stream-add/stream-remove — there is no per-source EOS message and no event-probe API. So within pyservicemaker there is currently no deterministic way to know a removed source's last frame has left the element.
nvqiezi commentedon Nov 25, 2026
@sergeykad could the open a new topic for the issue of "per-source EOS message"? Thank you!
sergeykad commentedon Nov 25, 2026
Thank you. We will not open a new issue for a per-source EOS message, because we no longer use
nvmultiurisrcbinfor files. Our file pipeline now feeds long-livedappsrcinputs, and our own code knows the end of each file from its frame count.Your
nvstreammuxpatch restored the frame count in all our runs (9 of 9 with 6,000 of 6,000 frames). The end of a file was one of several problems we measured withnvmultiurisrcbinunder file churn in 9.2, withlive-source=0and files added and removed through the REST API:From our side this issue can be closed once the patch ships in a release.