Jetson Nano, with PiCam2, Gstreamer, Gstreamer Pipeline

Gstreamer-1.0 Installation and Setup


      sudo add-apt-repository universe
      sudo add-apt-repository multiverse
      sudo apt-get update
      sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav
      sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev
        

Gstreamer Command

Gstreamer Example Pipeline Command


      gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink -e
        

The pipeline is constructed in a sequential line: {media source} ! {modification} ! {media sink} with '!' as the separator.

In the example command:

Media Source

The media source can be any media such as a camera stream, local media file, or network media file.

Modification

The modification section allows you to alter the media (e.g., flip, rotate, filter, convert file format, encode, decode, resize, payload stream).

Media Sink

The media sink is the destination where the media is displayed or forwarded to another network.

Camera Source

To list available cameras and supported formats:


      v4l2-ctl --list-devices
        

CSI Cameras

CSI cameras usually connect directly to the camera header on Nvidia Jetson or Raspberry Pi (e.g., RaspPi CamV2).

V4L2 Cameras

V4L2 cameras connect via USB (e.g., Logitech C series webcam). To install V4L2:


      sudo apt-get install v4l-utils
      v4l2-ctl --device=/dev/video0 --list-formats-ext
        

For more info, visit this link.

Camera Stream

RaspPi CamV2 Source


      gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)NV12, framerate=(fraction)30/1' ! nvoverlaysink -e
        

USB Camera Source


      gst-launch-1.0 v4l2src device="/dev/video1" ! "video/x-raw, width=640, height=480, format=(string)YUY2" ! xvimagesink -e
        

Camera Record

To record video and save to a file:


  gst-launch-1.0 nvarguscamerasrc maxperf=1 ! 'video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)NV12, framerate=(fraction)30/1' ! nvv4l2h265enc control-rate=1 bitrate=8000000 ! 'video/x-h265, stream-format=(string)byte-stream' ! h265parse ! qtmux ! filesink location=test.mp4 -e
          

Streaming RaspPi to VLC over RTSP Server

Ensure both Jetson Nano and PC are on the same network.

On Jetson Nano, install the RTSP server library:


      sudo apt-get install libgstrtspserver-1.0
        

Clone the gst-rtsp-server repository:


      git clone https://github.com/GStreamer/gst-rtsp-server
        

Navigate to the gst-rtsp-server-master/example directory:


      cd ~/gst-rtsp-server-master/example
      gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
        

Then run:


      sudo ./test-launch "videotestsrc ! nvvidconv ! nvv4l2h265enc ! h265parse ! video/x-h265, stream-format=byte-stream ! rtph265pay name=pay0 pt=96"
        

You can view the camera stream via VLC by accessing the network URL: rtsp://JETSON_IP:8554/test