nvarguscamerasrc plugin error


We have an django application which start Gstreamer with nvarguscamerasrc plugin. It starts the pipeline on request to API. So when 2 request are processed in the same time, one of them works fine, but other one just hangs after error:

Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:390 Failed to create CaptureSession

I know that I cannot access the camera device twice. I just want to handle the second situation properly. I could not found any errors in the pipeline bus, just this log on the stdout. I am using Gst1.0 from gi python package

Does anybody know how I can detect if the device is already used or the session is already created, or how to catch the above error from gstreamer?


There might be some ways to monitor argus deamon, but it would be weird and more complicated.

You just need a lock, you may simply use a semaphore, created with value 1 (one resource to lock), and then a thread may try to acquire it in non blocking mode. If it suceeds to get it it will launch the pipeline. Now other threads would fail to acquire it and would just bail out. After owner has finished with its pipeline, it would release the semaphore.

Thanks for the answer :)

We already tried with lock, it seems to work fine but we throw away this solution because semaphore could stay forever locked if something unexpected happens(management concerns).

On the other hand, obviously the nvarguscamerasrc plugin knows that the nvargus-deamon is busy and logs the above error. It just hangs after that and it never recovers from that state(even when the camera is released). It would be nice if the plugin just sets some error in gstreamer pipeline(or it sets but we don’t know where/how to search).

Are you able to share a gst-launch pipeline or test code to reproduce the issue?


I can provide pipeline similar to ours. If you run 2 times the same pipeline at the same time(please use 2 different files for the sink). The first run captures a video but the second one just hangs w/o error or something else. The file produced from the second run is 0 bytes. If you stop the first, nothing happens to the second run(does not start to capture a video or something else) and you should terminate it manually. I expected that second run will fail/exit at the beginning.

Here is the example pipeline(I am not an expert and there could be some misconfiguration):

gst-launch-1.0 -v nvarguscamerasrc ! "video/x-raw(memory:NVMM)" ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! omxh265enc ! matroskamux ! filesink location=testX.mkv


To reset camera and avoid capture session error you can use

sudo systemctl restart nvargus-daemon


Hope it helps.

1 Like

Hi @autoroboculture, thank you for the answer.

We already know this little workaround(we dig it out from the forum). It’s better than nothing, but it causes other issues.
For example: I do not want to close current capture session before starting a new one. I just want to receive error that capture session could not be created(for any reason), so I can handle it properly

Hi @nikki,
If you have only one camera, you cannot run two same pipelines simultaneously.

gst-launch-1.0 -v nvarguscamerasrc ! "video/x-raw(memory:NVMM)" ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! omxh265enc ! matroskamux ! filesink location=testX.mkv

You should use tee or nvtee.

If you have two cameras, you should specify ‘sensor-id’ in the two pipelines.

Hi @DaneLLL,

Actually I do not want to run them simultaneously. As I explained before, our pipeline is run by request handler. So if you make this request twice, you will fall in this pit. I just want to receive normal error from the second run(I think - it should be almost immediately, because camera is busy, and nvarguscamerasrc plugin knows that, because it cannot create a session), and then I can handle this error quietly w/o my whole API gets in irrecoverable state.

If we take an example from the real life: You cannot buy the last item in the store twice. For the second try you will receive: “Sorry, no more items”. Seller would not stuck and he will continue with his job.

We cannot reproduce the issue in running single pipeline + camera board ov5693 on r32.1. Please share more clear steps.

Just start the pipeline second time. You will see that the second run do not exit with error and freeze. And after that nvargus-daemon needs to be restarted if you want to capture anything else. I think this is not a normal behavior for any kind of software.

Here is sample output from gstreamer pipeline with v4l2src plugin instead of nvarguscamerasrc:

$gst-launch-1.0 v4l2src ! xvimagesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
libv4l2: error setting pixformat: Device or resource busy
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Device '/dev/video0' is busy
Additional debug info:
gstv4l2object.c(3451): gst_v4l2_object_set_format_full (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Call to S_FMT failed for YUYV @ 1280x720: Device or resource busy
Execution ended after 0:00:00.095442341
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

As you can see, if you run

gst-launch-1.0 v4l2src ! xvimagesink

twice, the gstreamer does not stuck on second call and exits properly with error Device '/dev/video0' is busy, all resources are freed. This is absolutely what I want from nvarguscamerasrc plugin to do.

We once again run the pipeline with camera board ov5693 on r32.1/Xavier and don’t hit the issue for 20+ runs.

$ gst-launch-1.0 nvarguscamerasrc ! "video/x-raw(memory:NVMM)" ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! omxh265enc ! matroskamux ! filesink location=testX.mkv

It is more like an issue in sensor driver. If you use other camera boards, please contact camera vendors to get further help.


20+ runs at the same time? Maybe I was not specific enough in last comment. Please run the second one when first pipeline is already running. Then the camera device is already taken and the issue occurs.
v4l2src handles it properly, and nvarguscamerasrc - not

When I said “Actually I do not want to run them simultaneously.” I mean that I do not expect that they will both produce output stream. I am still trying to run them at the same time, and I expect one of them to exit with error(as the example with v4l2src plugin).

Running two nvarguscamerasrc to the same single bayer sensor is invalid. You should run with tee

$ gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memoVMM),format=NV12' ! tee name=t t. ! queue ! nvvidconv ! nvoverlaysink t. ! queue ! nvvidconv ! omxh264enc ! filesink location= a.h264

Or use tegra_multimedia_api to create multiple streams through Argus. Two samples for your reference:


If you have to do error handling to this invalid case, please take @Honey_Patouceul’s suggestion to use semaphore or mutex.

Thanks for your time. We will try to avoid current situation somehow.