DeepStream SDK FAQ

26.[Deepstream6.2 Gst-nvstreammux & Gst-nvstreammux New]How to set parameters reasonably to improve the efficiency of nvstreammux in live mode

Gst-nvstreammux:

  • Set the batch-size to the number of sources
  • export NVSTREAMMUX_ADAPTIVE_BATCHING=yes
  • If you want to get high fps, set the batched-push-timeout to the (1000000 us/maximum fps among the videos)

Gst-nvstreammux New(export USE_NEW_NVSTREAMMUX=yes):

  • Set the batch-size to the number of sources
  • Should not turn off the adaptive-batching parameter
  • Please refer to the following basic tuning principles first:Gst-nvstreammux Tuning parameters
  • Set the max-same-source-frames to ceil(maximum fps/minimum fps)
  • Set the max-num-frames-per-batch of each source to ceil(current fps/minimum fps)

Experiment: There are 3 live sources with fps 15, 25 and 30 respectively for runtime source addition/deletion scenarios. We’ll delete the video of 25 fps when the pipeline is running.

Build rtsp server:

  • Install FFmpeg $ sudo apt-get install ffmpeg
  • $docker run --rm -it --network=host aler9/rtsp-simple-server
  • Prepare videos with different frame rates: 15fps.mp4 25fps.mp4 30fps.mp4
  • Open a new terminal and run: $ffmpeg -re -stream_loop -1 -i 15fps.mp4 -c:v copy -an -f rtsp -rtsp_transport tcp rtsp://127.0.0.1:8554/stream0
  • Open a new terminal and run: $ffmpeg -re -stream_loop -1 -i 25fps.mp4 -c:v copy -an -f rtsp -rtsp_transport tcp rtsp://127.0.0.1:8554/stream1
  • Open a new terminal and run: $ffmpeg -re -stream_loop -1 -i 30fps.mp4 -c:v copy -an -f rtsp -rtsp_transport tcp rtsp://127.0.0.1:8554/stream2

Build demo code:
config_mux_source3.txt (2.9 KB)
deepstream_test_rt_src_add_del.c (26.1 KB)
Makefile (2.0 KB)

 $cd /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/
 $git clone https://github.com/NVIDIA-AI-IOT/deepstream_reference_apps.git
 $cd deepstream_reference_apps/runtime_source_add_delete/

Replace files in the directory with attached files
 $cp deepstream_test_rt_src_add_del.c ./deepstream_test_rt_src_add_del.c
 $cp Makefile ./Makefile
 $cp config_mux_source3.txt ./
 $export CUDA_VER=11.8
 $make

Run:

  • ./deepstream-test-rt-src-add-del 0 filesink 1
  • You can add and delete streams by pressing “a” and “d” on the keyboard.

FPS For Streams with Gst-nvstreammux :

  • Set batched-push-timeout to 70000 ms > 1000000 us/ 15fps
    1. Start with all streams
     **PERF: 14.03 (14.95)   25.05 (24.98)   25.05 (24.92)
     **PERF: 15.26 (14.95)   24.42 (24.98)   24.42 (24.92)
     **PERF: 14.71 (14.95)   25.51 (24.98)   25.51 (24.92)
     **PERF: 15.04 (14.95)   25.07 (24.98)   25.07 (24.92)
    
    1. Delete the stream source of 25 fps
     **PERF: 14.52 (14.96)   16.59 (23.21)   0.00 (19.20)
     **PERF: 15.53 (14.96)   16.66 (23.19)   0.00 (19.13)
     **PERF: 14.73 (14.96)   16.49 (23.17)   0.00 (19.07)
     **PERF: 14.51 (14.96)   16.58 (23.14)   0.00 (19.00)
    
  • Set batched-push-timeout to 40000 ms = 1000000 us/ 25fps
    1. Start with all streams
     **PERF: 15.12 (13.89)   30.24 (28.01)   25.20 (23.92)
     **PERF: 14.94 (13.91)   29.88 (28.03)   24.90 (23.93)
     **PERF: 14.98 (13.91)   29.95 (28.03)   24.32 (23.93)
     **PERF: 15.01 (13.93)   10.32 (27.84)   25.63 (23.95)
    
    1. Delete the stream source of 25 fps
     **PERF: 14.47 (14.27)   24.80 (28.13)   0.00 (21.76)
     **PERF: 15.51 (14.28)   24.84 (28.11)   0.00 (21.61)
     **PERF: 14.95 (14.28)   24.92 (28.09)   0.00 (21.46)
     **PERF: 14.83 (14.29)   24.83 (28.07)   0.00 (21.31)
    
  • Set batched-push-timeout to 20000 ms < 1000000 us/ 30 fps
    1. Start with all streams
     **PERF: 15.00 (14.82)   29.58 (36.49)   24.81 (25.10)
     **PERF: 14.94 (14.85)   30.09 (35.51)   25.08 (25.09)
     **PERF: 15.07 (14.88)   30.38 (34.65)   25.14 (24.98)
     **PERF: 15.00 (14.89)   29.54 (34.22)   24.78 (25.07)
    
    1. Delete the stream source of 25 fps
     **PERF: 14.97 (14.83)   30.11 (30.67)   0.00 (23.22)
     **PERF: 15.07 (14.83)   30.11 (30.65)   0.00 (22.71)
     **PERF: 14.92 (14.83)   29.71 (30.64)   0.00 (22.21)
     **PERF: 14.95 (14.84)   30.22 (30.62)   0.00 (21.73)
    

FPS For Streams with Gst-nvstreammux New:
A. Plugin Parameters Settings:

  • max-same-source-frames=1
  • 15 fps video: max-num-frames-per-batch=1
  • 25 fps video: max-num-frames-per-batch=1
  • 30 fps video: max-num-frames-per-batch=1
    1. Start with all streams
     **PERF: 15.22 (14.54)   14.00 (14.88)   14.42 (13.84)
     **PERF: 13.89 (14.55)   14.58 (14.86)   14.13 (13.82)
     **PERF: 14.00 (14.54)   14.00 (14.84)   14.42 (13.84)
     **PERF: 15.00 (14.55)   14.59 (14.82)   13.46 (13.85)
    
    1. Delete the stream source of 25 fps
     **PERF: 13.46 (14.52)   15.00 (14.81)   0.00 (13.35)
     **PERF: 15.22 (14.51)   14.00 (14.79)   0.00 (13.07)
     **PERF: 13.89 (14.51)   14.58 (14.77)   0.00 (12.80)
     **PERF: 14.00 (14.50)   14.00 (14.75)   0.00 (12.54)
    

B. Plugin Parameters Settings:

  • max-same-source-frames=2
  • 15 fps video: max-num-frames-per-batch=1
  • 25 fps video: max-num-frames-per-batch=2
  • 30 fps video: max-num-frames-per-batch=2
    1. Start with all streams
     **PERF: 14.79 (14.90)   29.68 (29.84)   25.58 (24.86)
     **PERF: 15.16 (14.90)   30.09 (29.86)   24.32 (24.88)
     **PERF: 14.89 (14.90)   29.87 (29.87)   25.88 (24.90)
     **PERF: 15.09 (14.90)   30.38 (29.87)   24.30 (24.88)
    
    1. Delete the stream source of 25 fps
     **PERF: 15.04 (14.94)   30.08 (29.92)   0.00 (17.51)
     **PERF: 14.94 (14.94)   29.86 (29.92)   0.00 (17.32)
     **PERF: 15.00 (14.94)   29.85 (29.92)   0.00 (17.15)
     **PERF: 15.08 (14.95)   30.54 (29.93)   0.00 (16.97)