Failure to use gst-launch-1.0 nvarguscamerasrc to capture image

Jespack version is 5.1.1. GStreamer version is 1.16.3. I use a CSI camera and if I run vgstcapture-1.0 the images can be captured. But if I turn to export DISPLAY=:0 and

gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), \
     width=(int)1920, height=(int)1080, format=(string)NV12, \
     framerate=(fraction)30/1' ! queue ! nvdrmvideosink -e

The error occurs:

Invalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keynvbufsurftransform: Could not get EGL display connection
Setting pipeline to PAUSED ...
Could not open DRM failed 
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstNvDrmVideoSink:nvdrmvideosink0: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
Additional debug info:
gstbasesink.c(5367): gst_base_sink_change_state (): /GstPipeline:pipeline0/GstNvDrmVideoSink:nvdrmvideosink0:
Failed to start
Setting pipeline to NULL ...
Freeing pipeline ...

If I don’t input export DISPLAY=:0, the error becomes:

Setting pipeline to PAUSED ...
Could not open DRM failed 
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstNvDrmVideoSink:nvdrmvideosink0: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
Additional debug info:
gstbasesink.c(5367): gst_base_sink_change_state (): /GstPipeline:pipeline0/GstNvDrmVideoSink:nvdrmvideosink0:
Failed to start
Setting pipeline to NULL ...
Freeing pipeline ...

Can you help me fix this?

hello 1075471989,

please give it a try with below pipeline to enable preview stream, i.e. xvimagesink.
for instance,
$ gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),framerate=30/1,format=NV12' ! nvvidconv ! xvimagesink

It works! Thank you. Can you explain why it could work? And if I want to make a pipeline for cv2.VideoCapture, how to create it? The former demo in CSI_Camera repository doesn’t work anymore.

hello 1075471989,

I rarely using nvdrmvideosink, you may try adding nvvidconv for converting the formats for testing.
for example,
$ gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1' nvvidconv ! 'video/x-raw(memory:NVMM), format=(string)I420' ! queue ! nvdrmvideosink -e

you may see-also Topic 140648 for samples using cv2.VideoCapture

Hi JerryChang,

Thank you for reply. If I use the provided pipeline like


    video_capture = cv2.VideoCapture("gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1' nvvidconv ! 'video/x-raw(memory:NVMM), format=(string)I420' ! queue ! nvdrmvideosink -e") 
    if video_capture.isOpened():
        try:
            window_handle = cv2.namedWindow(window_title, cv2.WINDOW_AUTOSIZE)
            while True:
                ret_val, frame = video_capture.read()
                if cv2.getWindowProperty(window_title, cv2.WND_PROP_AUTOSIZE) >= 0:
                    cv2.imshow(window_title, frame)
                else:
                    break 
                keyCode = cv2.waitKey(10) & 0xFF
                # Stop the program on the ESC key or 'q'
                if keyCode == 27 or keyCode == ord('q'):
                    break
        finally:
            video_capture.release()
            cv2.destroyAllWindows()
    else:
        print("Error: Unable to open camera")

It just prints Error: Unable to open camera so it still doesn’t work. If I run the pipeline in terminal, it returns

(gst-launch-1.0:10432): GStreamer-CRITICAL **: 10:13:22.323: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
WARNING: erroneous pipeline: could not parse caps "video/x-raw(memory:NVMM),\ width=(int)1920,\ height=(int)1080,\ format=(string)NV12,\ framerate=(fraction)30/1 nvvidconv"

Can you help me fix this such that I can use it as a pipeline?

please refer to… OpenCV VideoCapture is not wokring - #13 by DaneLLL

Okay I will try that one after a new problem is solved. I just updated the jetpack from 5.1.1 to 5.1.3, and then if I run
gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),framerate=30/1,format=NV12' ! nvvidconv ! xvimagesink,
the camera window is black and can’t show anything. Do you know why?
For your information, below is codes in the terminal:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Caught SIGSEGV
Spinning.  Please run 'gdb gst-launch-1.0 7310' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

hello 1075471989,

may I know how you updated the jetpack from 5.1.1 to 5.1.3,
please also check whether device registration has complete, i.e. $ dmesg > klog.txt

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.