Gst-launch-1.0 failed to capture video

System information (version)

Platform =>TX2(the carrier board is designed by myself)

Flash OS =>Jetpack3.3(R28.2.1)

camera sensor =>Sony IMX185(designed by myself)

OpenCV => 3.4.1(compile it from source reference:<a target='_blank' rel='noopener noreferrer' href='https://www.jetsonhacks.com/2018/05/28/build-opencv-3-4-with-cuda-on-nvidia-jetson-tx2/'>https://www.jetsonhacks.com/2018/05/28/build-opencv-3-4-with-cuda-on-nvidia-jetson-tx2/</a>)

I have changed the tegra186-quill-p3310-1000-c03-00-base.dtb and flashed in my TX2.

It seems that IMX185 have been loaded onto TX2.Here is log about imx185

nvidia@tegra-ubuntu:~$ dmesg | grep -i imx185
[    2.764612] imx185 1-001a: [IMX185]: probing v4l2 sensor at addr 0x1a.
[    2.767065] imx185 1-001a: imx185_fuse_id_setup,  fuse id: 000085010101
[    2.767156] imx185 1-001a: Detected IMX185 sensor
[    4.714222] tegra-vi4 15700000.vi: subdev imx185 1-001a bound

When I execute this command(“nvgstcapture-1.0”),it can capture video on my screen.

nvidia@tegra-ubuntu:~$ nvgstcapture-1.0
Encoder null, cannot set bitrate!
Encoder Profile = High
Supported resolutions in case of ARGUS Camera
  (2) : 640x480
  (3) : 1280x720
  (4) : 1920x1080
  (5) : 2104x1560
  (6) : 2592x1944
  (7) : 2616x1472
  (8) : 3840x2160
  (9) : 3896x2192
  (10): 4208x3120
  (11): 5632x3168
  (12): 5632x4224

Runtime ARGUS Camera Commands:

  Help : 'h'
  Quit : 'q'
  Set Capture Mode:
      mo:<val>
          (1): image
          (2): video
  Get Capture Mode:
      gmo
  Set sensor orientation:
      so:<val>
          (0): none
          (1): Rotate counter-clockwise 90 degrees
          (2): Rotate 180 degrees
          (3): Rotate clockwise 90 degrees
  Get sensor orientation:
      gso
  Set Whitebalance Mode:
      wb:<val>
          (0): off
          (1): auto
          (2): incandescent
          (3): fluorescent
          (4): warm-fluorescent
          (5): daylight
          (6): cloudy-daylight
          (7): twilight
          (8): shade
          (9): manual
  Get Whitebalance Mode:
      gwb
  Set Saturation (0 to 2):
      st:<val> e.g., st:1.25
  Get Saturation:
      gst
  Capture: enter 'j' OR
           followed by a timer (e.g., jx5000, capture after 5 seconds) OR
           followed by multishot count (e.g., j:6, capture 6 images)
           timer/multihot values are optional, capture defaults to single shot with timer=0s
  Start Recording : enter '1'
  Stop Recording  : enter '0'
  Video snapshot  : enter '2' (While recording video)
  Get Preview Resolution:
      gpcr
  Get Image Capture Resolution:
      gicr
  Get Video Capture Resolution:
      gvcr


Runtime encoder configuration options:

  Set Encoding Bit-rate(in bytes):
      br:<val> e.g., br:4000000
  Get Encoding Bit-rate(in bytes):
      gbr
  Set Encoding Profile(only for H.264):
      ep:<val> e.g., ep:1
          (0): Baseline
          (1): Main
          (2): High
  Get Encoding Profile(only for H.264):
      gep
  Force IDR Frame on video Encoder(only for H.264):
      Enter 'f' 


bitrate = 4000000
Encoder Profile = High
** Message: <main:5684> iterating capture loop ....
GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 0 
   Output Stream W = 640 H = 480 
   seconds to Run    = 0 
Framerate set to : 30 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
^C** Message: <_intr_handler:5104> User Interrupted.. 

Terminating the camera pipeline ...
GST_ARGUS: Cleaning up
CONSUMER: Done Success
GST_ARGUS: Done Success
** Message: <main:5694> Capture completed
** Message: <main:5745> Camera application will now exit

However,it was failed when i executed gst-launch-1.0

nvidia@tegra-ubuntu:~$ gst-launch-1.0 nvcamerasrc ! 'video/x-raw(memory:NVMM),witdth=1920,height=1080,format=NV12,framerate=(fraction)30/1' ! nvoverlaysink -e
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
Setting pipeline to NULL ...
Freeing pipeline ...

I also use opencv to capture video from my IMX185.Bur failed.

std::string get_tegra_pipeline(int width, int height, int fps)
{ return "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)I420, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw,format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink";
}

The error message:

OpenCV(3.4.1-dev) Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp, line 890
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

OpenCV(3.4.1-dev) /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp:890: error: (-2) GStreamer: unable to start pipeline
 in function cvCaptureFromCAM_GStreamer

Hi,
On r28.2.1, we have nvarguscamerasrc. Could you give it a try?

$ gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1920,height=1080,format=NV12' ! nvoverlaysink

Of course, I have try it.

nvidia@tegra-ubuntu:~$ gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),witdth=1920,height=1080,format=NV12,framerate=(fraction)30/1' ! nvoverlaysink -e
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 0 
   Output Stream W = 1 H = 1080 
   seconds to Run    = 0 
GST_ARGUS: Creating output stream
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:389 Failed to create OutputStream

There is a typo in your command ‘witdth=1920’

Aha,I got it.
I will read the latest TX2_Accelerated_GStreamer carefully.
Thank you!

What’s the difference between nvcamerasrc and nvarguscamerasrc?
When I use Opencv3.4.2(compiled by myself)+gstreamer(nvarguscamersrc) to capture, it only got stuck for a few frames.
However,i use nvcamerasrc instead of nvarguscamerasrc,there is a delay in capturing video images, and the imaging effect is not good.

Hi,
nvarguscamerasrc is new plugin in order to unify interfaces between tegra_multimedia_api and gstreamer.

We have deprecated nvcamerasrc in r32.1 release.

I just changed the version of OpenCV, and the other environments have not changed.

Hi,
If nvarguscamerasrc is good for your usecase, please use it.

I have a problem when i use nvarguscamerasrc+opencv3.4.2(Manual installation), only a few frames can be captured and then the appliacation is crashed.

However,I ues opencv3.4.1(compile it from source reference:https://www.jetsonhacks.com/2018/05/28/build-opencv-3-4-with-cuda-on-nvidia-jetson-tx2/),it will not encounter this problem.

Is OpenCV3.4.2 not compatible with Gstreamers?

Hi,
We have verified opencv3.4.0 at
[url]https://devtalk.nvidia.com/default/topic/1042892/jetson-agx-xavier/nvarguscamerasrc-opencv-solved-/post/5290833/#5290833[/url]

Can you check if the sample works on 3.4.2?
You should be able to install 3.4.2 by modifying the script from 3.4.0 to 3.4.2:
https://github.com/AastaNV/JEP/blob/master/script/install_opencv3.4.0_TX2.sh