Stream Runcam Webcam using RTSP

Hi all,

I have a runcam Webcam connected through USB to the Jetson nano and I’ve been trying to stream it’s image through RTSP to view it, for instance, on a windows machine using VLC.

I’ve gone through the FAQ and also followed several tickets in the forum concerning streaming video from a USB camera through RTSP (This one was quite useful)

Here is what I get when I run:

v4l2-ctl -d /dev/video1 --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'MJPG' (compressed)
        Name        : Motion-JPEG
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 800x600
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 960x720
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1024x576
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'H264' (compressed)
        Name        : H.264
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 800x600
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 960x720
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1024x576
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)

        Index       : 2
        Type        : Video Capture
        Pixel Format: 'YUYV'
        Name        : YUYV 4:2:2
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 320x180
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 352x288
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 432x240
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 800x448
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 800x600
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 864x480
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 960x720
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1024x576
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.040s (25.000 fps)

In the jetson nano itself I was able to see the camera output by running:

gst-launch-1.0 v4l2src device=/dev/video1 io-mode=2 ! image/jpeg,width=1280,height=720,framerate=30/1 ! nvjpegdec ! video/x-raw ! xvimagesink

But when I run:
./test-launch "v4l2src device=/dev/video1 io-mode=2 ! image/jpeg,width=1280,height=720,framerate=30/1 ! nvjpegdec ! video/x-raw ! omxh265enc ! rtph265pay name=pay0 pt=96"

And try to read it from VLC on windows it fails to open:
main debug: using renderer_discovery module “microdns”

main debug: processing request item: rtsp://192.168.178.46:8554/test, node: Playlist, skip: 0

main debug: rebuilding array of current - root Playlist

main debug: rebuild done - 4 items, index 3

main debug: starting playback of new item

main debug: resyncing on rtsp://192.168.178.46:8554/test

main debug: rtsp://192.168.178.46:8554/test is at 3

main debug: creating new input thread

main debug: Creating an input for 'rtsp://192.168.178.46:8554/test'

main debug: requesting art for new input thread

main debug: using timeshift granularity of 50 MiB

main debug: using timeshift path: C:\Users\vicen\AppData\Local\Temp

main debug: `rtsp://192.168.178.46:8554/test' gives access `rtsp' demux `any' path `192.168.178.46:8554/test'

main debug: creating demux: access='rtsp' demux='any' location='192.168.178.46:8554/test' file='\\192.168.178.46:8554\test'

main debug: looking for access_demux module matching "rtsp": 15 candidates

live555 debug: version 2016.11.28

main debug: looking for meta fetcher module matching "any": 1 candidates

lua debug: Trying Lua scripts in C:\Users\vicen\AppData\Roaming\vlc\lua\meta\fetcher

lua debug: Trying Lua scripts in D:\Program Files (x86)\VideoLAN\VLC\lua\meta\fetcher

main debug: no meta fetcher modules matched

main debug: looking for art finder module matching "any": 2 candidates

lua debug: Trying Lua scripts in C:\Users\vicen\AppData\Roaming\vlc\lua\meta\art

lua debug: Trying Lua scripts in D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art

lua debug: Trying Lua playlist script D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\00_musicbrainz.luac

lua debug: skipping script (unmatched scope) D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\00_musicbrainz.luac

lua debug: Trying Lua playlist script D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\01_googleimage.luac

lua debug: skipping script (unmatched scope) D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\01_googleimage.luac

lua debug: Trying Lua playlist script D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\02_frenchtv.luac

lua debug: skipping script (unmatched scope) D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\02_frenchtv.luac

lua debug: Trying Lua playlist script D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\03_lastfm.luac

lua debug: skipping script (unmatched scope) D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\03_lastfm.luac

main debug: no art finder modules matched

main debug: looking for meta fetcher module matching "any": 1 candidates

lua debug: Trying Lua scripts in C:\Users\vicen\AppData\Roaming\vlc\lua\meta\fetcher

lua debug: Trying Lua scripts in D:\Program Files (x86)\VideoLAN\VLC\lua\meta\fetcher

main debug: no meta fetcher modules matched

main debug: looking for art finder module matching "any": 2 candidates

lua debug: Trying Lua scripts in C:\Users\vicen\AppData\Roaming\vlc\lua\meta\art

lua debug: Trying Lua scripts in D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art

lua debug: Trying Lua playlist script D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\00_musicbrainz.luac

lua debug: Trying Lua playlist script D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\01_googleimage.luac

lua debug: Trying Lua playlist script D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\02_frenchtv.luac

lua debug: Trying Lua playlist script D:\Program Files (x86)\VideoLAN\VLC\lua\meta\art\03_lastfm.luac

main debug: no art finder modules matched

qt debug: IM: Setting an input

live555 debug: we will now try HTTP tunneling mode

live555 debug: connection error -10057

live555 error: Failed to connect with rtsp://192.168.178.46:8554/test

main debug: no access_demux modules matched

main debug: creating access: rtsp://192.168.178.46:8554/test

main debug: (path: \\192.168.178.46:8554\test)

main debug: looking for access module matching "rtsp": 27 candidates

satip debug: try to open 'rtsp://192.168.178.46:8554/test'

satip debug: connect to host '192.168.178.46'

main debug: net: connecting to 192.168.178.46 port 8554

main debug: connection succeeded (socket = 2344)

main debug: net: opening 0.0.0.0 datagram port 9416

main debug: net: opening 0.0.0.0 datagram port 9417

satip error: Failed to setup RTSP session

main debug: net: connecting to 192.168.178.46 port 8554

main debug: connection succeeded (socket = 2344)

access_realrtsp warning: Cseq mismatch, got 1, assumed 0

access_realrtsp debug: rtsp connected

access_realrtsp warning: only real/helix rtsp servers supported for now

main debug: no access modules matched

main debug: dead input

qt debug: IM: Deleting the input

main debug: changing item without a request (current 3/4)

main debug: nothing to play

main debug: removing module "microdns"

If I try to use the command:
gst-launch-1.0 uridecodebin uri=rtsp://127.0.0.1:8554/test ! nvoverlaysink

directly from JetsonNano I only get the following output:

RTSP output

Any idea what I could be missing?

Hi,
We have deprecated omx plugins. Please try

./test-launch "v4l2src device=/dev/video1 io-mode=2 ! image/jpeg,width=1280,height=720,framerate=30/1 ! nvjpegdec ! video/x-raw ! nvvidconv ! nvv4l2h265enc ! rtph265pay name=pay0 pt=96"

Or try nvv4l2decoder for MJPEG decoding:

./test-launch "v4l2src device=/dev/video1 io-mode=2 ! image/jpeg,width=1280,height=720,framerate=30/1 ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvv4l2h265enc ! rtph265pay name=pay0 pt=96"
2 Likes

Both work! Fantastic!! I guess this one is solved, thank a lot!

But since “I have you here”, I’ll take advantage to ask a couple of more related questions:

  • I have about 1.5 seconds of delay. Do you know if it can be improved somehow? Reducing stream definition doesn’t seem to have any effect (or very little).

  • This camera also has a microphone. Could sound also be streamed through the test-launch app? Is it just a matter of the configuration string being passed as a parameter?

  • I’ve been struggling to find some documentation on how to understand and tweak the “configuration string” passed as a parameter to both test-launch or gst-launch. Could you please point me to it?

Cheers,
Carlos

Hi
The delay may be from network or source. You may run the command to check glass-to-glass latency first:

gst-launch-1.0 v4l2src device=/dev/video1 io-mode=2 ! image/jpeg,width=1280,height=720,framerate=30/1 ! jpegparse ! nvv4l2decoder mjpeg=1 ! nvoverlaysink

For launching audio source, please refer to
Live streaming cam usb - #4 by DaneLLL

test-launch is a sample in native gstreamer package. For further question about it, please go to gstreamer forum

Actually if I use this command I do get an extremely laggy image accompanied by by the following errors:

WARNING: from element /GstPipeline:pipeline0/GstNvOverlaySink-nvoverlaysink:nvoverlaysink-nvoverlaysink0: A lot of buffers are being dropped.
Additional debug info:
gstbasesink.c(2902): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstNvOverlaySink-nvoverlaysink:nvoverlaysink-nvoverlaysink0:
There may be a timestamping problem, or this computer is too slow.
WARNING: from element /GstPipeline:pipeline0/GstNvOverlaySink-nvoverlaysink:nvoverlaysink-nvoverlaysink0: A lot of buffers are being dropped.

On the other hand if a run:

gst-launch-1.0 v4l2src device=/dev/video1 io-mode=2 ! image/jpeg,width=1280,height=720,framerate=30/1 ! nvjpegdec ! video/x-raw ! xvimagesink

It runs smoothly with negligible delay.