2

I have a fresh installed Buster(Release Date: 2020-08-20) on my Pi4B

I am able to stream with pi Camera by doing

gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,width=1280,height=720,framerate=30/1 ! clockoverlay time-format="%H:%M:%S %d.%m.%Y" outline-color=-16777216 color=-1 draw-shadow=false font-desc="myriad pro bold expanded 16" ! omxh264enc target-bitrate=1000000 control-rate=variable ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=x.x.my.ip port=8004

But when I use the same command with my webcam, which is at "/dev/video0", I got the below error:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.001112783
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

The webcam(brand name is rapoo) I am using is compatible with my pi. I can see live video from it by running:

gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! ximagesink

Also tested it with fswebcam 123.jpg -d /dev/video0. It also works for my Pi camera in /dev/video1

May I know how can I do a rtp UDP stream with my webcam?

Marcus L
  • 31
  • 1
  • 5

1 Answers1

1

Figured it out! It works fine on my pi cam because it supported H264 natviely.

You could check the format supported by the webcam by doing:

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

For my webcam, it only supports YUYV and MJPEG: v4l2-ctl --list-formats-ext -d /dev/video0:

pi@raspberrypi:~ $ v4l2-ctl --list-formats-ext -d /dev/video0
 ioctl: VIDIOC_ENUM_FMT
 Type: Video Capture
Size: Discrete 1280x720
    Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 640x480
    Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 320x240
    Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 160x120
    Interval: Discrete 0.050s (20.000 fps)
Size: Discrete 1280x720
    Interval: Discrete 0.100s (10.000 fps)
    Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 640x480
    Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 320x240
    Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 160x120
    Interval: Discrete 0.040s (25.000 fps)

So I need to use JPEG format and then convert it to H264, and finally output it as rtp udp to my server:

gst-launch-1.0 -vv -e v4l2src device=/dev/video0  ! \
"image/jpeg,width=640,height=480" ! queue ! jpegdec ! videoconvert ! \
omxh264enc target-bitrate=1000000 control-rate=variable ! h264parse ! rtph264pay config- 
interval=1 pt=96 ! udpsink host=my.server.ip port=5000
Marcus L
  • 31
  • 1
  • 5