I need to stream raspivid video via UDP instead TCP in a multicast fashion.


raspivid -w 640 -h 480 -vf -ih -fps 30 -n -o udp://dest_address:12345

I can stream the video trough UDP on dest_address host where I can play it with:

vlc udp://@:12345 :demux=h264... it works fine.

Unluckly I need a server like approach:

  1. In the real case I don't know host dest_address but I know its network address (and mask and so on) and therefore broadcast address of such net;
  2. At least a second host should be allowed to connect and receive the same stream;
  3. I need it to be as much realtime as possibile (at least on the first host connected host).

the command line above does not fit my need (raspivid will not listen for UDP connections).

I tried using netcat in this way:

raspivid -w 640 -h 480 -vf -ih -fps 30 -n -o - | nc -lu 12345

and then tried to stream it trough vlc (tried several urls and command line options) but nothing seems to work.

I previoulsy used raspivid and netcat to simulate a TCP video server in this way

raspivid -w 640 -h 480 -vf -ih -fps 30 -n -o - | nc -l -p 12345

and it works fine but it only accept a single client.

P.S. I'm not an expert in TCP/IP and/or UDP networking (and maybe I should have misunderstood some basic concept) but I'm willing to learn.

1 Answer 1


I have tried to do this a few times but never gotten the results I wanted. Just recently I revisited it and found this works to multicast directly from raspivid.

raspivid -a 12 -a "ras2" -t 0 -b 3000000 -fps 20 -w 1920 -h 1080 -o udp:// -ih -fl -stm -if adaptive -pf main -v -n

Then use this on a linux PC to view:

vlc udp://@ --demux=h264

I was actually very surprised because all the solutions I googled mention streaming through VLC or netcat or using uv4l instead of raspivid. This exhibits slightly over 1 second latency which is pretty fantastic I think. I didn't have a second host convenient but I was able to start two instances of VLC on the same host.

The Raspberry Pi I am using is a Pi 2 running stretch and using the native Pi camera.

I can't take credit for any of the above. It was cobbled together from many many sources found googling and as noted I just for giggles tried outputting to a multicast address.

  • I need to check for your solution to work in system but I bet it works fine. Nevertheless it will be unapplyable in my case since I need a much lover latency (not more than 200ms)
    – weirdgyn
    Jan 1, 2021 at 11:17
  • unfortunately none of this works for me. My vlc on the receiving end runs on Windows 10 and doesn't show anything :-(. Feb 2, 2021 at 16:14
  • I suggest researching topics about enabling receipt of multicast on winows 10 like this one: "support.microsoft.com/en-us/topic/…"
    – shawn
    Feb 3, 2021 at 18:04
  • Also note the --demux h264 argument is required.
    – shawn
    Feb 3, 2021 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.