Skip to content

Instantly share code, notes, and snippets.

@crawc
Forked from drzax/iptv-to-hls.sh
Created September 10, 2018 23:50
Show Gist options
  • Save crawc/4774a4d3344290a0bc6f80c7481ede32 to your computer and use it in GitHub Desktop.
Save crawc/4774a4d3344290a0bc6f80c7481ede32 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:[email protected]/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