Skip to content

Instantly share code, notes, and snippets.

@why404
Created March 5, 2015 05:08
Show Gist options
  • Save why404/00a0eccc38045095b069 to your computer and use it in GitHub Desktop.
Save why404/00a0eccc38045095b069 to your computer and use it in GitHub Desktop.
#!/bin/sh
INPUT_FILE="clock.flv";
if [ ! -f "$INPUT_FILE" ]; then
echo "clock.flv not found, start downloading...\n"
curl -o "clock.flv" "http://ykgroup.qiniudn.com/clock4.flv"
fi
#TELECOM
#HOSTS=("115.231.96.121" "115.231.101.10" "106.38.227.9" "119.254.100.101:80");
#UNICOM
HOSTS=("101.71.27.121" "124.160.148.130" "111.206.234.143" "119.254.100.101:80");
STREAM_NAME=$RANDOM;
RTMP_URL_ARRAY=();
PUSH_URL_ADDRESS="";
for host in ${HOSTS[*]}; do
URL=rtmp://$host/live/test$STREAM_NAME;
RTMP_URL_ARRAY+=($URL);
PUSH_URL_ADDRESS+=" -f flv $URL";
done;
nohup ffmpeg -re -i $INPUT_FILE -c copy $PUSH_URL_ADDRESS >/dev/null 2>&1 &
ps auwx | grep ffmpeg
sleep 3s;
for url in ${RTMP_URL_ARRAY[*]}; do
nohup ffplay -rtmp_live 1 -rtmp_buffer 3000 $url >/dev/null 2>&1 &
done;
# kill -9 $(ps aux | grep ffmpeg | awk '{print $2}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment