Skip to content

Instantly share code, notes, and snippets.

@lyarinet
Forked from drzax/iptv-to-hls.sh
Created October 9, 2021 17:15
Show Gist options
  • Save lyarinet/4f7690918a1bafb1f13c0e5446efb0d1 to your computer and use it in GitHub Desktop.
Save lyarinet/4f7690918a1bafb1f13c0e5446efb0d1 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