"m3u8 Proxy" fr HLSv5/v7 - Streams aus der Bouquet.tv Kanalliste starten.
#copyright by dam72, free to use, change and share 

Was sind HLSv5/v7 Streams?
DreamOS2.5 kann HLSv3 Streams direkt mittels HW-Player 1:0:1 o. 4097:0:1 aus der bouquet.tv Kanalliste abspielen. Bei HLSv3 sind Video und Audio im einem *.ts Conatiner zusammengemuxt.
Bei HLSv5/v7 ist das anders, dort bekommt jeder Elementar Stream einen eigenen m3u8 Stream zugewiesen. Der Player multiplext Video und Audio zusammen zum Abspielen. Genau dieses zusammenmuxen kann der HW Player in DreamOS2.5 nicht.

Warum dieser Proxy? 
Damit man diese HLSv5/v7 Streams, mit separatem Video und Audio stream, dennoch aus der Kanalliste abgespielt werden knnen, muss man dem HW Player einen gemuxten Stream bergeben, der Video und Audio in einem Container enthlt. 
Grob gesagt macht der "m3u8 Proxy" nichts anderes.

Wer nutzt HLSv5/v7 Streams?
Inzwischen sind nahezu alle Live-Sender der ARD&ZDF Mediathek auf diesen Standard gewechselt. Auch Telerising (Zattoo,Teleboy,SKYCH,u.a) sind dann damit aus der Kanalliste nutzbar. 
In erster Linie war es eine Spielerei, die ich vor knapp 10 Monaten angefangen habe, da ich die Live Streams von ARD/ZDF nutzen wollte. Fr DreamOS2.6 gibt es das ffmpegproxy, das es fr DreamOS2.5 nicht gibt. 
Und da ich eine dm920 habe und bei DreamOS2.5 beleiben wollte, hab ich das Problem selber gelst. Vielleicht kann es ja jemand gebrauchen.

Disclaimer: Ich bin nur ein Hobby Skripter und mache das in meiner Freizeit, wenn es meine wenige Zeit erlaubt. Sicherlich kann man das schner/ander lsen. Aber fr mich funktioniert es.

Was liefere ich mit?
1x ffmpeg_d -> das ist ein statischer ffmpeg 5.0 build, der u.a. auch https kann, was das ffmpeg im DreamOS2.5 nicht macht.
1x udpxy -> das ist eine kleiner udp to http proxy, mit dem ich zwei Fliegen mit einer Klatsche erschlage.
1x Start&Monitoring Skript fr den m3u8 proxy, der checked das bestimmte Files nicht zu gross werden und ob das Hauptskript luft.
1x Pseudo m3u8 Playlist "play.m3u8", in die mein Skript schreibt und er ffmpeg_d abspielt.
1x bouquet.tv mit den Live Streams von den ARD/ZDF Mediatheken

In welche Ordner kommen diese Dateien?
ffmpeg_d in /usr/bin chmod 755
udpxy in /usr/bin chmod 755
bouquet.tv in /etc/enigma2 und den Eintrag in der bouquet.tv nicht vergessen.
proxy_m3u8.sh nach /etc/init.d chmod 755
alle anderen in den Ordner /data/m3u8_proxy/ , chmod 755 nicht vergessen.


Wie funktioniert das ganze?
Beispielhaft an "DasErste" erklrt. 
Folgende URL ( http://127.0.0.1:32034/udp/227.0.0.0:92/prox/m3u8_ARD ) wird beim Zappen in der bouquet.tv aufgerufen
#SERVICE 1:0:1:0:0:0:0:0:0:0:http%3a//127.0.0.1%3a32034/udp/227.0.0.0%3a92/prox/m3u8_ARD:ARD_Mediathek
#DESCRIPTION ARD_Mediathek
Die eigentliche URL ist http://127.0.0.1:32034/udp/227.0.0.0:92/prox/m3u8_ARD. Eigentlich wird damit der udpxy instruiert den multicast 227.0.0.0:92 als MPEG-TS unicast stream umszusetzen.
Der Zusatz /prox/m3u8_ARD wird beim Zappen im e2 System abgefangen und im Skript mit der echten m3u8 URL gemappt, gemapped-> ["m3u8_ARD"]="https://mcdn.daserste.de/daserste/de/master.m3u8"
Die echte URL wird dann "aufgelst", und in eine neue lokale play.m3u8 geschrieben, die dann an ffmpeg bergeben wird und auf der Multicast 227.0.0.0:92 ausgespielt wird und von udpxy abgefangen an den HW Player bergeben wird. 
-> Bild und Ton erscheinen auf dem TV.

Wie lege ich neue Sender an?
in der Bouquet.tv einen neuen Sender anlegen z.B. mit 
http://127.0.0.1:32034/udp/227.0.0.0:92/prox/m3u8_NeuerSender
sieht in der Bouquet dann so aus:
#SERVICE 1:0:1:0:0:0:0:0:0:0:http%3a//127.0.0.1%3a32034/udp/227.0.0.0%3a92/prox/m3u8_NeuerSender:NeuerSender_Mediathek
#DESCRIPTION NeuerSender_Mediathek
Dann im Skript das Mapping fr NeuerSender anlegen. Das Skript ist in /data/m3u8_proxy/proxy_m3u8_resolv.sh
Dort die echte URL zum HLS Stream hinzufgen -> ["m3u8_NeuerSender"]="https://URL_Neuer_Sender/master.m3u8"
Speichern und das Skript neu starten.

Was ist zu beachten?
- Man sollte nicht zu schnell zappen. 
- Manchmal dauert es ein paar Sekunden bis Bild und Ton synchronsiert waren.
P.S: Das war das grsste Problem, eine Lsung zu finden, wo Bild und Ton immer synchro sind. Die lokale play.m3u8 war die Lsung.

Wie luft das Skript automatisch?
cd /etc/init.d
proxy_m3u8.sh nach /etc/init.d chmod 755
update-rc.d proxy_m3u8.sh defaults
Das startet das Skript beim bootup.

Im crontab diese diesen erstellen.
crontab -e , dann einfgen
* * * * * sleep 30; /data/m3u8_proxy/proxywatch_k.sh
update-rc.d busybox-cron defaults
/etc/init.d/busybox-cron start &



#####################################################################################################################################################################################

English translation

"m3u8 Proxy" for HLSv5/v7 - Start streams from the Bouquet.tv channel list.
#copyright by dam72, free to use, change and share 

What are HLSv5/v7 streams?
DreamOS2.5 can play HLSv3 streams directly from the bouquet.tv channel list using HW Player 1:0:1 or 4097:0:1. With HLSv3, video and audio are combined in a *.ts Conatiner.
HLSv5/v7 is different, each elementary stream is assigned its own m3u8 stream. The player multiplexes video and audio together for playback. This is exactly what the HW Player in DreamOS2.5 cannot do.

Why this proxy? 
In order to be able to play these HLSv5/v7 streams with separate video and audio streams from the channel list, the HW Player must be given a muxed stream containing video and audio in one container. 
Roughly speaking, the "m3u8 proxy" does this combining job.

Who uses HLSv5/v7 streams?
In the meantime, almost all live broadcasters of the ARD&ZDF Mediathek have switched to this standard. Telerising (Zattoo,Teleboy,SKYCH,and others) can then also be used with this solution. 
First and foremost it was a gimmick that I started about 10 months ago because I wanted to use the live streams from ARD/ZDF. For DreamOS2.6 there is the ffmpegproxy, which is not available for DreamOS2.5. 
And since I have a dm920 and wanted to stay with DreamOS2.5, I solved the problem myself. Maybe someone can benefit from it too.

Disclaimer: I'm just a hobby scripter and do this in my spare time when my little time allows. Surely you can solve this in a nicer/different way. But for me it works.

What do I supply?
1x ffmpeg_d -> this is a static ffmpeg 5.0 build, which also supports https, which the ffmpeg in DreamOS2.5 does not.
1x udpxy -> this is a small udp to http proxy, with which I kill two birds with one stone...
1x Start&Monitoring script for the m3u8 proxy, which checks that certain files don't get too big and if the main script is running.
1x pseudo m3u8 playlist "play.m3u8", into which my script writes and it plays ffmpeg_d.
1x bouquet.tv with the live streams from the ARD/ZDF media libraries.

Which folders do these files go into?
ffmpeg_d in /usr/bin chmod 755
udpxy in /usr/bin chmod 755
bouquet.tv in /etc/enigma2 and don't forget the entry in bouquet.tv.
all others into the folder /data/m3u8_proxy/ , dort forget chmod 755

How does the whole thing work?
Explained using "DasErste" as an example. 
The following URL ( http://127.0.0.1:32034/udp/227.0.0.0:92/prox/m3u8_ARD ) is called up when zapping in the bouquet.tv
#SERVICE 1:0:1:0:0:0:0:0:0:0:http%3a//127.0.0.1%3a32034/udp/227.0.0.0%3a92/prox/m3u8_ARD:ARD_Mediathek
#DESCRIPTION ARD_Mediathek
The actual URL is http://127.0.0.1:32034/udp/227.0.0.0:92/prox/m3u8_ARD. Actually this instructs the udpxy to convert the multicast 227.0.0.0:92 as MPEG-TS unicast stream.
The /prox/m3u8_ARD addition is intercepted during zapping in the e2 system and mapped in the script with the real m3u8 URL, mapped-> ["m3u8_ARD"]="https://mcdn.daserste.de/daserste/de/master.m3u8".
The real URL is then "resolved", and written to a new local play.m3u8, which is then passed to ffmpeg and played out on the multicast 227.0.0:92 and intercepted by udpxy and passed to the HW player. 
-> Picture and sound appear on the TV.

How do I create new channels?
Create a new channel in Bouquet.tv, e.g. with 
http://127.0.0.1:32034/udp/227.0.0.0:92/prox/m3u8_NeuerSender
will then look like this in the bouquet:
#SERVICE 1:0:1:0:0:0:0:0:0:0:http%3a//127.0.0.1%3a32034/udp/227.0.0.0%3a92/prox/m3u8_NeuerSender:NeuerSender_Mediathek
#DESCRIPTION NewSender_Mediathek
Then create the mapping for NewSender in the script. The script is in /data/m3u8_proxy/proxy_m3u8_resolv.sh
Add the real URL to the HLS stream there -> ["m3u8_NeuerSender"]="https://URL_Neuer_Sender/master.m3u8".
Save and restart the script.

What should be noted?
- You should not zap too fast. 
- Sometimes it takes a few seconds until picture and sound are synchronised.
P.S: That was the biggest problem, to find a solution where picture and sound are always synchro. The local play.m3u8 was the solution.

How does the script run automatically?
cd /etc/init.d
upload proxy_m3u8.sh in /etc/init.d chmod 755
update-rc.d proxy_m3u8.sh defaults
Starts the script at bootup.
In the crontab create this entry
crontab -e , add this
* * * * * sleep 30; /data/m3u8_proxy/proxywatch_k.sh
update-rc.d busybox-cron defaults
/etc/init.d/busybox-cron start &

