How to send video stream over UDP network by RTP

42/5000
How to send video stream over UDP network by RTP,the stream is UYVY format and from V4L2 framework using YUV camera

Hi,
You may refer to Jetson Nano FAQ
Q: I have a USB camera. How can I lauch it on Jetson Nano?
Q: Is there any example of running RTSP streaming?

Hi,
I want Applications Using GStreamer with V4L2 Source Plugin For a YUV sensor with the format UYVY to run RTSP streaming.

I just know how to Save the preview into a file as follows
gst-launch-1.0 -v v4l2src device=/dev/video0 ! ‘video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480, framerate=(fraction)30/1’ ! nvvidconv ! ‘video/x-raw(memory:NVMM), format=(string)NV12’ ! omxh264enc ! qtmux ! filesink location=test.mp4 -ev

how can I run RTSP streaming.

Hi,
You can launch the pipeline through test-launch.

gcc test-launch.c -o test-launch (pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)

Package gstreamer-rtsp-server-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gstreamer-rtsp-server-1.0.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘gstreamer-rtsp-server-1.0’ found
test-launch.c:20:10: fatal error: gst/gst.h: No such file or directory
#include <gst/gst.h>
^~~~~~~~~~~
compilation terminated.

Hi,
You probably don’t install certain gstreamer packages. Please check Jetson Nano FAQ and execute the steps one by one.

gcc test-launch.c -o test-launch (pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)

test-launch.c: In function ��‘main��’:
test-launch.c:77:3: warning: implicit declaration of function ��‘gst_rtsp_media_factory_set_enable_rtcp��’; did you mean ��‘gst_rtsp_media_factory_set_latency��’? ]
gst_rtsp_media_factory_set_enable_rtcp (factory, !disable_rtcp);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gst_rtsp_media_factory_set_latency
/tmp/ccof2XmD.o: In function main': test-launch.c:(.text+0x154): undefined reference to gst_rtsp_media_factory_set_enable_rtcp’
collect2: error: ld returned 1 exit status

Hi,
We can build it successfully.

nvidia@xavier8G:~$ gcc test-launch.c -o test-launch (pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
-bash: syntax error near unexpected token `('
nvidia@xavier8G:~$ gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
nvidia@xavier8G:~$ ls
a.jpg          Desktop           opencv4.3.0  test-launch
a.yuv          Documents         Pictures     test-launch.c
bug_200618410  Downloads         Public       Videos
bug_200669225  examples.desktop  Templates    VisionWorks-SFM-0.90-Samples
cmake-3.13.5   Music 

$sudo apt-get install libgstrtspserver-1.0 libgstreamer1.0-dev
gcc test-launch.c -o test-launch (pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)

test-launch.c: In function ��‘main��’:
test-launch.c:77:3: warning: implicit declaration of function ��‘gst_rtsp_media]
gst_rtsp_media_factory_set_enable_rtcp (factory, !disable_rtcp);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gst_rtsp_media_factory_set_latency
/tmp/ccTPL49B.o: In function main': test-launch.c:(.text+0x154): undefined reference to gst_rtsp_media_factory_set’
collect2: error: ld returned 1 exit status

I run these on Xavier , did the gcc on Xavier have problem?

thinks ,I built it successfully.
But when I execute ./test-launch “videotestsrc ! nvvidconv ! nvv4l2h264enc ! h264parse ! rtph264pay name=pay0 pt=96” ,the process exits without printing any information

Hi,
Would be great if you can re-flash the Xavier through SDKManager. It looks unstable and meets the issues we never see. Might be helpful if the system image can be refreshed.

You may add option is-live=true to videotestsrc:

./test-launch "videotestsrc is-live=true ! video/x-raw, width=640, height=480, framerate=20/1 ! nvvidconv ! video/x-raw(memory:NVMM), width=640, height=480, framerate=20/1, format=NV12 ! omxh264enc insert-vui=true insert-sps-pps=1 ! video/x-h264, stream-format=byte-stream, alignment=au ! h264parse ! rtph264pay name=pay0 pt=96 "

$./test-launch "videotestsrc is-live=true ! video/x-raw, width=1920, height=1080, framerate=20/1 ! nvvidconv ! video/x-raw(memory:NVMM), width=1920, height=1080, framerate=20/1, format=UYVY8 ! omxh264enc insert-vui=true insert-sps-pps=1 ! video/x-h264, stream-format=byte-stream, alignment=au ! h264parse ! rtph264pay name=pay0 pt=96 ! "

stream ready at rtsp://127.0.0.1:8554/test

thinks!
I use UYVY8 camera , it has ISP,so i use nvarguscamera-bypass way to capture the streams.

I use
./test-launch "v4l2src device = /dev/video0 ! nvvidconv ! omxh264enc insert-vui=true insert-sps-pps=1 ! video/x-h264, stream-format=byte-stream, alignment=au ! h264parse ! rtph264pay name=pay0 pt=96"
on Xavier
I can sea the streams on PC useing
gst-launch-1.0 uridecodebin uri=rtsp://<SERVER_IP_ADDRESS>:8554/test ! xvimagesink

but why the streams has more then 3s` delay

uridecodebin is a meta plugin that will instanciate several sub plugins and connect them together through caps filters.
For a rtsp uri, it would use rstpsrc meta plugin, that will in turn use rtpjitterbuffer plugin. This plugin has a latency parameter for buffering with default value of 2000 ms, so this explains most of what you’re seeing (the rest being mostly encoding/packetisation and depacketisation/decoding).
uridecodebin doesn’t expose this latency parameter, but has many parameters that you may try to play with:

gst-inspect-1.0 uridecodebin

Alternately, you may try this pipeline where you would be able to set latency, but be aware that excessively low value may lead to issues and may not give better performance. I’ d suggest to try first in 200-500 ms range. This depends on your LAN, interfaces…

# From the jetson (through localhost interface no LAN problem)
gst-launch-1.0 -e rtspsrc location=rtsp://127.0.0.1:8554/test latency=500 ! application/x-rtp, media=video, encoding-name=H264 ! queue ! decodebin ! nvvidconv ! xvimagesink

# From any other kind of Linux host on same LAN:
gst-launch-1.0 -e rtspsrc location=rtsp://your_jetson_IP:8554/test latency=500 ! application/x-rtp, media=video, encoding-name=H264 ! queue ! decodebin ! xvimagesink

xavier:
$gst-launch-1.0 v4l2src device = /dev/video0 ! nvvidconv ! omxh264enc insert-vui=true insert-sps-pps=1 ! video/x-h264, stream-format=byte-stream, alignment=au ! h264parse ! rtph264pay name=pay0 pt=96 ! udpsink host=192.168.1.100 port=5000 sync=false async=false

pc:
$gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! queue ! avdec_h264 ! xvimagesink sync=false async=false -e

it works,thanks!