Gstreamer pipeline works in command line but not in app

I am using OpenCV with Java, built the OpenCV library with Java bindings.

I am trying to run the following command for VideoCapture but it does not work within the app, however it works fine with filesink on command line…

The parameters for video frame width and height are 1280 and 720 respectively, and the frame rate is set to 30.

        String commandString = "nvarguscamerasrc !" +
                "video/x-raw(memory:NVMM),format=NV12," +
                "width=" + videoFrameWidth + "," +
                "height=" + videoFrameHeight + "," +
                "framerate=" + frameRate + "/1 ! " +
                "queue !" +
                "nvvidconv flip-method=" + rotationParameter +" ! " +
                "queue !" +
                "nvv4l2h264enc !" + "appsink";

        videoCapture = new VideoCapture(commandString, CAP_GSTREAMER);

This is the output I am seeing from the app:

Opening in BLOCKING MODE
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected…
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 2592 x 1944 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 34000, max 550385000;

GST_ARGUS: 2592 x 1458 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 34000, max 550385000;

GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 22000, max 358733000;

GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 2
Output Stream W = 1280 H = 720
seconds to Run = 0
Frame Rate = 120.000005
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
[ WARN:0@1.438] global /home/nicolasgaray/opencv/opencv-4.5.5/modules/videoio/src/cap_gstreamer.cpp (2402) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module nvarguscamerasrc0 reported: Internal data stream error.
GST_ARGUS: Cleaning up
CONSUMER: Done Success
GST_ARGUS: Done Success

The same pipeline is run on command line as

gst-launch-1.0 nvarguscamerasrc ! ‘video/x-raw(memory:NVMM),format=NV12,width=1280,height=720,framerate=30/1’ ! nvvidconv flip-method=2
! nvv4l2h264enc ! filesink location=test2.h264

Why does this not work with appsink?

I got it to work using the following command string if anyone is curios.

        String commandString = "nvarguscamerasrc ! " +
                // Source parameters - how video is captured
                "video/x-raw(memory:NVMM), " +
                "width=(int)" + videoFrameWidth + ", " +
                "height=(int)" + videoFrameHeight + ", " +
                "format=(string)NV12, " +
                "framerate=(fraction)" + frameRate + "/1 ! " +
                // Rotate the video
                "nvvidconv flip-method=" + rotationParameter +" ! " +
                // Convert to jpeg for recording as Motion JPG
                "nvjpegenc" +
                // Send it back to the calling app
                "! appsink";

Glad to know issue resolved, thanks for the sharing!

1 Like

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