Skip to content

Instantly share code, notes, and snippets.

@drzax
Created June 1, 2017 05:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save drzax/99c468b0c695491784109a4cf21c1c1b to your computer and use it in GitHub Desktop.
Save drzax/99c468b0c695491784109a4cf21c1c1b to your computer and use it in GitHub Desktop.
IPTV to HTTP live streaming
#!/bin/bash
while true; do
currTime=`date +%Y%m%d%H%M`
if [ "$currTime" -ge 201507081658 -a "$currTime" -le 201507082300 ]; then
echo "$currTime: Stream should be on. Start ffmpeg if the process does not exist"
if [ "$(pidof ffmpeg)" ]; then
echo "$currTime: ffmpeg already running."
sleep 10
else
echo "$currTime: ffmpeg not running. Start it"
ffmpeg -i 'udp://239.193.4.70:5000' -vcodec libx264 -profile:v high -level:v 4.1 -crf 23 -preset veryfast -vf "yadif" -s 640x320 -maxrate 800k -bufsize 1600k -hls_wrap 16 -acodec libmp3lame -ac 2 -b:a 128k -strict experimental "ftp://iptv1:8gm2taXx@69.163.202.29/tv.elvery.net/hls.m3u8" &
fi
else
echo "$currTime: Stream should be off. Kill ffmpeg if the process exists"
killall ffmpeg
sleep 10
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment