-
Notifications
You must be signed in to change notification settings - Fork 21
Multicast streaming in the local network
Mark Van den Borre edited this page Oct 17, 2016
·
7 revisions
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.
#!/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'
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
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.
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 $?
- http://streambuilder.pro/docs/how-tos/working-with-udp-multicast-mpeg-ts-streams-on-linux/
- picking up the multicast mpeg ts stream inside a docker image might be less than trivial:
- https://github.com/docker/docker/issues/23659
- http://stackoverflow.com/questions/37214608/docker-receiving-multicast-traffic
- recent improvements seem to make this easier https://gist.github.com/nerdalert/c0363c15d20986633fda
- http://blog.scottlowe.org/2016/01/28/docker-macvlan-interfaces/
- https://github.com/docker/libnetwork/blob/master/docs/macvlan.md
- http://networkstatic.net/configuring-macvlan-ipvlan-linux-networking/