Skip to content

Multicast streaming in the local network

Mark Van den Borre edited this page Oct 17, 2016 · 7 revisions

idea

The idea is to be able to push UDP streams in the network, so they can be ingested from the video mixer (voctocore), and monitored in the same time by separate servers/workstations.

pushing

#!/bin/bash

# these are needed, because the default socket size is too small.
echo 81921024 > /proc/sys/net/core/wmem_max
echo 81921024 > /proc/sys/net/core/wmem_default

echo 81921024 > /proc/sys/net/core/rmem_max
echo 81921024 > /proc/sys/net/core/rmem_default

/usr/local/bin/bmd-streamer -f /usr/lib/firmware -k 1000 -S hdmi -F 0 | ffmpeg -i - -c copy -f mpegts 'udp://227.0.0.2:9000&overrun_nonfatal=1&buffer_size=81921024&fifo_size=178481'

pushing with recording (to be tested a bit more)

ttee is at https://github.com/krokodilerian/ttee. Needs care when compiling on 32bit systems to be able to write to files >4GB.

#!/bin/bash

# these are needed, because the default socket size is too small.
echo 81921024 > /proc/sys/net/core/wmem_max
echo 81921024 > /proc/sys/net/core/wmem_default

echo 81921024 > /proc/sys/net/core/rmem_max
echo 81921024 > /proc/sys/net/core/rmem_default

# pipe to push through
mknod av.ts p

# NOTE this will not restart properly if just ffmpeg dies. needs work

/usr/local/bin/bmd-streamer -f /usr/lib/firmware -k 1000 -S hdmi -F 0 |ttee  av.ts /ssd/log.`date +%s`.ts &
ffmpeg -i av.ts -c copy -f mpegts 'udp://227.0.0.2:9000&overrun_nonfatal=1&buffer_size=81921024&fifo_size=178481'

Version 3, without ttee, using the 'tee' output of ffmpeg:

  • note that in this version it would actually be possible to dump to an mp4 container instead of MPEG-TS one, but there's not really a point, as we would need to chew these files anyway.
#!/bin/bash

# these are needed, because the default socket size is too small.
echo 81921024 > /proc/sys/net/core/wmem_max
echo 81921024 > /proc/sys/net/core/wmem_default

echo 81921024 > /proc/sys/net/core/rmem_max
echo 81921024 > /proc/sys/net/core/rmem_default

# pipe to push through

/usr/local/bin/bmd-streamer -f /usr/lib/firmware -k 1000 -S hdmi -F 0 | ffmpeg -i av.ts -c copy -f tee '[mpegts]udp://227.0.0.2:9000&overrun_nonfatal=1&buffer_size=81921024&fifo_size=178481|[mpegts]/ssd/log.'`date +%s`.ts

viewing

mpv udp://227.0.0.2/

Otherwise, see mon.sh in https://github.com/krokodilerian/fostest as an example how to monitor multiple such streams.

monitoring

This tells you if the stream is alive:

mpv -vo null -ao null -frames 0 --network-timeout=10 udp://227.0.0.5:9000; echo $?

various

Clone this wiki locally