I need to run several apps on a Jetson Orin Nano, each app on a docker container. The app needs to access an RTSP Stream and for that I use OpenCV VideoCapture class. I created a simple App that only opens the RTSP Stream (based on a gstreamer pipeline) gathers frames and prints out the FPS on the terminal every 100 frames.
It happens that when I launch multiple containers of the app when I am using the software decoder one of the containers cannot open the stream. In every experiment I did this happened. However If I use the Hardware decoder instead all the containers can make the connection. Just to see if the pipeline that uses the software decoder had any issue I run the app on the Jetson Nano without using docker and to my surprise I was able to run 13 apps at the same time, so it sounds like the issue comes from docker I guess.
Here is the zip folder with all you need to replicate the issue.
replicte_material.zip (15.3 KB)
How to run multiple Apps on a Jetson Machine
Build the docker image first
-
./build_docker_image.sh -
Create an RTSP server (Use VLC probably it is the easiest way)
-
Change the
RTSP_URLenv variables in the.envfile to match your RTSP url, leave theHW_DECODER=0as it is (The App will use Software Decoder in the gstreamer pipeline)
Run 6 App instances:
- docker_multi_instance.sh start 6
Check logs on a different terminal
- tail -f /var/log/syslog
Look for a log that says:Error: Unable to open camera.
If it shows this message means the container was not able to open the Stream
Run the App without using Docker
Open the file single_instance_no_docker.shand change the variables RTSP_URL and set HW_DECODER=0
to use the software decoder
Open several terminals and on each run:
./single_instance_no_docker.sh
You should see something like this:
Main Question
Why one of the containers when using Software decoder cannot connect to the RTSP Stream. And why does this not happen when using Hardware decoder or when not using docker?
Pipelines
Here are the Pipelines I am using in case you do not want to check the source code
Software decoder
"rtspsrc location=" + rtsp_url + " drop-on-latency=true ! rtph264depay ! h264parse ! queue ! avdec_h264 ! queue ! videoconvert ! appsink max-buffers=1 drop=true"
Hardware Decoder
"rtspsrc location=" + rtsp_url + " drop-on-latency=true ! \ rtph264depay ! \ h264parse config-interval=-1 ! \ queue ! \ nvv4l2decoder ! \ nvvidconv ! video/x-raw,format=BGRx ! \ videoconvert ! video/x-raw,format=BGR ! \ queue ! \ videorate ! video/x-raw,framerate= ! \ appsink max-buffers=1 drop=true"
