Skip to content

Instantly share code, notes, and snippets.

@luke10x
Last active October 31, 2015 23:39
Show Gist options
  • Save luke10x/14838183b4e76a615bbc to your computer and use it in GitHub Desktop.
Save luke10x/14838183b4e76a615bbc to your computer and use it in GitHub Desktop.
sound travel
#/bin/bash
FIFO=/tmp/recast-fifo
rm $FIFO
mkfifo $FIFO
(while true; do cat $FIFO | pv | nc -u 127.0.0.1 14999; NC_PID_1=$!; done) &
TCP_PULL_PID=$!
(while true; do nc 0.0.0.0 14888 >$FIFO; NC_PID_2=$!; done) &
UDP_PUSH_PID=$!
trap 'killme' INT
killme () {
echo "Killing processes"
kill -9 $TCP_PULL_PID 2>/dev/null
kill -9 $NC_PID_1 2>/dev/null
kill -9 $UDP_PUSH_PID 2>/dev/null
kill -9 $NC_PID_2 2>/dev/null
kill -9 $$
}
wait
#!/bin/bash
FIFO=/tmp/cast-fifo
rm $FIFO
mkfifo $FIFO
amixer sset Capture cap
ffmpeg -f alsa -ac 2 -i plughw:0,0 -acodec libmp3lame -ab 8k -threads 0 -f rtp rtp://127.0.0.1:14888 &
FFMPEG_PID=$!
(while true; do nc -l -u -p 14888 1>$FIFO; NC_PID_1=$!; done) &
IN_PID=$!
(while true; do nc -l -p 14888 0<$FIFO; NC_PID_2=$!; done) &
OUT_PID=$!
trap 'killme' INT
killme () {
echo "Killing processes"
kill -9 $FFMPEG_PID 2>/dev/null
kill -9 $IN_PID 2>/dev/null
kill -9 $NC_PID_1 2>/dev/null
kill -9 $OUT_PID 2>/dev/null
kill -9 $NC_PID_2 2>/dev/null
kill -9 $$
}
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment