Last active
July 10, 2023 18:22
-
-
Save HNJAMeindersma/df85f9224163b41ac1738b29e022b4a1 to your computer and use it in GitHub Desktop.
TVheadend pipe creator from .m3u
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install TVheadend | |
curl -1sLf 'https://dl.cloudsmith.io/public/tvheadend/tvheadend/setup.deb.sh' | sudo -E bash | |
sudo apt update && sudo apt install -y tvheadend | |
# Install ffmpeg piper | |
sudo apt install -y curl ffmpeg | |
sudo mkdir /etc/tvheadend && sudo chmod a=rwx /etc/tvheadend | |
echo "#!/bin/sh | |
curl -sS $1 | sed '/^http/ s/$/ -vcodec copy -acodec copy -f mpegts -tune zerolatency pipe:1/' | sed '/^http/ s/^/pipe:\/\/\/usr\/bin\/ffmpeg -loglevel fatal -i /' | |
# For unstable connectivity: curl -sS $1 | sed '/^http/ s/$/ -codec copy -map 0 -f mpegts -tune zerolatency pipe:1/' | sed '/^http/ s/^/pipe:\/\/\/usr\/bin\/ffmpeg -loglevel fatal -reconnect 1 -reconnect_streamed 1 -reconnect_on_network_error 1 -reconnect_on_http_error 1 -fflags -nobuffer -err_detect ignore_err -i /' | |
# Add 'IPTV Automatic Network' in TVheadend with URL: 'pipe:///bin/sh /etc/tvheadend/piper.sh https://iptv-org.github.io/iptv/countries/uk.m3u' | |
" | sudo tee /etc/tvheadend/piper.sh | |
# EPG install and setup | |
sudo apt install -y git nodejs npm | |
sudo mkdir /etc/tvheadend && sudo chmod a=rwx /etc/tvheadend | |
cd /etc/tvheadend && git clone --depth 1 -b master https://github.com/iptv-org/epg.git && cd epg && sudo npm install | |
echo "15 * * * * iptv cd /etc/tvheadend/epg && SITE=example.com npm run grab >/dev/null 2>&1" | sudo tee -a /etc/crontab | |
echo "45 * * * * hts cat /etc/tvheadend/epg/guides/en/example.com.xml | nc -w 5 -U /var/lib/tvheadend/epggrab/xmltv.sock >/dev/null 2>&1" | sudo tee -a /etc/crontab | |
# Setup USB-IP client | |
# TO-DO | |
# sudo modprobe vhci_hcd | |
# Install TBSXXXX driver | |
sudo apt install -y linux-headers-`uname -r` patchutils libproc-processtable-perl gcc | |
mkdir ~/tbsdriver && cd ~/tbsdriver | |
git clone https://github.com/tbsdtv/media_build.git | |
git clone --depth=1 https://github.com/tbsdtv/linux_media.git -b latest ./media | |
cd media_build | |
make dir DIR=../media | |
make allyesconfig | |
sed -i -r 's/(^CONFIG.*_RC.*=)./\1n/g' v4l/.config | |
sed -i -r 's/(^CONFIG.*_IR.*=)./\1n/g' v4l/.config | |
make -j4 | |
sudo make install | |
mkdir ~/tbsfirmware && cd ~/tbsfirmware | |
wget http://www.tbsdtv.com/download/document/linux/tbs-tuner-firmwares_v1.0.tar.bz2 | |
sudo tar jxvf tbs-tuner-firmwares_v1.0.tar.bz2 -C /lib/firmware/ | |
sudo reboot | |
# DVB quality control | |
sudo apt install -y dvb-apps dvb-tools dvbsnoop | |
femon -H -a 0 -f 0 | |
dvb-fe-tool --femon -a 0 -f 0 | |
dvb-fe-tool -g -a 0 -f 0 | |
dvbsnoop -s signal -frontend /dev/dvb/adapter0/frontend0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
curl -sS $1 | sed '/^http/ s/$/ -vcodec copy -acodec copy -f mpegts -tune zerolatency pipe:1/' | sed '/^http/ s/^/pipe:\/\/\/usr\/bin\/ffmpeg -loglevel fatal -i /' | |
# For unstable streams: curl -sS $1 | sed '/^http/ s/$/ -codec copy -map 0 -f mpegts -tune zerolatency pipe:1/' | sed '/^http/ s/^/pipe:\/\/\/usr\/bin\/ffmpeg -loglevel fatal -reconnect 1 -reconnect_streamed 1 -reconnect_on_network_error 1 -reconnect_on_http_error 1 -fflags -nobuffer -err_detect ignore_err -i /' | |
# Possible audio out-of-sync when using: -probesize 1000k -analyzeduration 0 -fpsprobesize 0 | |
# Added to pipe every audio and subtitle stream: -map 0 | |
# Not working on Ubuntu Server 22.04 LTS default repo ffmpeg: -reconnect_delay_max 2000 -reconnect_at_eof 1 | |
# HOWTO use | |
# - Save this script as "/etc/tvheadend/piper.sh" or a location of your choice | |
# - Add 'IPTV Automatic Network' in TVheadend with URL: "pipe:///bin/sh /etc/tvheadend/piper.sh https://iptv-org.github.io/iptv/countries/uk.m3u" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install USB-IP from default RPi/Debian repository | |
sudo apt install -y usbip | |
# Create USB-IP daemon service | |
echo "[Unit] | |
Description=USB-IP host daemon | |
After=network-online.target | |
[Service] | |
Type=forking | |
ExecStartPre=/sbin/modprobe usbip-host | |
ExecStart=/usr/sbin/usbipd -D | |
[Install] | |
WantedBy=multi-user.target | |
" | sudo tee /etc/systemd/system/usbipd.service | |
# Create USB-IP binding service | |
echo "[Unit] | |
Description=USB-IP binding on USB ID %I | |
After=network-online.target usbipd.service | |
Wants=network-online.target | |
Requires=usbipd.service | |
[Service] | |
Type=simple | |
ExecStart=/bin/sh -c "/usr/sbin/usbip bind -b $(sudo usbip list -p -l | grep %i | grep -oP '(?<=busid=).*?(?=#)')" | |
RemainAfterExit=yes | |
ExecStop=/bin/sh -c "/usr/sbin/usbip unbind -b $(sudo usbip list -p -l | grep %i | grep -oP '(?<=busid=).*?(?=#)')" | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
" | sudo tee /etc/systemd/system/[email protected] | |
# Enable USB-IP services | |
sudo systemctl daemon-reload | |
sudo systemctl enable usbipd.service | |
sudo systemctl enable usbip-bind@XXXX:XXXX.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment