2

I have a fisheye usb webcam attached to a raspberry pi that I'm trying to stream to a computer. I've played with ffmpeg and it seems a little laggy beyond 320x240. From what I've read people have been happy with gstreamer.

So I've tested the usb webcam and it works locally

gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw,width=640,height=480' ! glimagesink

These are the commands I've been trying to use to get the video to my computer. However, all I'm seeing is a green window.

TCP Sever:gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw,width=640,height=480,framerate=30/1' ! x264enc byte-stream=true ! rtph264pay ! gdppay ! tcpserversink host=192.168.200.38 port=5000 sync=false

TCP Client: gst-launch-1.0 -v tcpclientsrc host=192.168.200.38 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

or

UDP Server: gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw,width=640,height=480,framerate=30/1' ! x264enc byte-stream=true ! rtph264pay ! gdppay ! udpsink host=192.168.200.37 port=5000 sync=false

UDP Client: gst-launch-1.0 -v udpsrc port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

I figure I must be piping the plugins wrong somehow. Any advice is appreciated.

James
  • 2,742
  • 1
  • 20
  • 43
  • I think they are part of the arguments passed to gst-launch-1.0. they get interpreted as video 'pipes' and the output of each plugin gets passed to the next plugin, separated by the exclamation mark. – James Mar 15 '16 at 23:27
  • Okay. Makes sense that it uses a custom pipe character to distinguish it from regular pipes using `|` – jDo Mar 15 '16 at 23:36
  • BUT WHAT AM I DOING WRONG ???|||??? – James Mar 15 '16 at 23:40

2 Answers2

2

So I've twiddled things for a day and got it working. I'll post what I have so far. The queue lets the rpi multi-thread the h264 encoding portion and I've sub-ed omxh264enc for x264enc because it is openmax/accelerated. Both changes help latency.

I guess I didn't need gdppay? (saw someone stream without it here Stream webcam video with gstreamer 1.0 over UDP to PC)

rpi side

gst-launch-1.0 -vv -e v4l2src device=/dev/video0 ! "video/x-raw,width=640,height=480" ! queue ! omxh264enc ! h264parse ! rtph264pay ! udpsink host=192.168.200.37 port=5000

computer side

gst-launch-1.0 -vv -e udpsrc port=5000 ! application/x-rtp, payload=96 ! rtph264depay ! queue ! avdec_h264 ! videoconvert ! autovideosink sync=false

Community
  • 1
  • 1
James
  • 2,742
  • 1
  • 20
  • 43
1

Try below methods first:

  1. Add tune=zerolatency after your x264enc (this usually need in embedded system)
  2. Recheck IP and connection (I see the IP is different in TCP and UDP case)

If the problem is not still solved yet, make clear some points:

  1. What video format is provided by your camera (add " -v" after your first command, it will tell you)
  2. Is that format supported by x264enc?
    (according to its manual, x264enc support I420, YV12, Y42B, Y444, NV12, I420_10LE, I422_10LE, Y444_10LE)
    • If the format is not supported, try another camera, or another encoder.
    • If it is supported, try to confirm your encode command (with filesink/fakesink) and decode comand (with videotestsrc)
matilda gl
  • 319
  • 1
  • 6
  • The TCP is a pull model and the UDP is a push model, my Raspberry Pi is at 192.168.200.38, computer is at 192.168.200.37. – James Mar 17 '16 at 03:06