Raspivid low latecy streaming and saving

1k views Asked by At

I'm trying to save and stream the Raspi Camera trough wifi at 10FPS with a Rpi Zero W (no serverX)

I need to save in full frame and high resolution that suppose to use MJPEG codec. That is done by this command :

raspivid -md 2 -w 2592 -h 1944 -fps 10 -cd MJPEG -fl -f -t 0 -o videoOut.mjpeg

That is working fine and uses only 6% of CPU.

Then I need to stream in 640x480. My idea is to stream the preview from raspivid with a Rpi screen resolution set to 640x480.

To get very low latency I have to use WebRTC (https://github.com/mpromonet/webrtc-streamer).

I don't want to use UV4L to stay open source.

Webrtc-streamer manages screens but seems only with ServerX.

Does anybody have an idea?

Thanks!

1

There are 1 answers

1
O. Jones On

It's difficult, or even impossible, to do low-latency streaming by screencasting a video preview window. There are simply too many steps that take a whole frame time each.

  1. Grab a camera frame and translate it from the YCrCb 4:2:0 color space to RGB 1:1:1.
  2. Draw it on the X Window System display server.
  3. Grab it from the display surface, translate it back to YCrCb, and compress it.
  4. Push it over the net to a viewer.
  5. Decode and render it.

That's five frame times, or half a second at 10fps.

You're much better off capturing the compressed stream directly. The Broadcom RPi processor has video compression hardware built in, and can produce compressed data streams in just over one frame time. It can render the preview window concurrently with producing the compressed video stream.

And WebRTC handles the network aspects of streaming quite well.