German livestream as tvheadend IPTV stream

  • Hi,


    when Germany switched to DVB T 2, I didn't want to buy new hardware and tried to use IPTV as my tvheadend network. In the following post I want to provide some tips, so that other people run into the same issues.

    I assume you have installed tvheadend and added an IPTV network in configuration --> networks. If not, simply click "add" and choose "IPTV automatic network".

    Getting the stream to work

    What I did was to create a mux xyz_stream for each channel and then add a service xyz for each mux. The hard part was to get the live-stream url into the mux configuration. To do this I used a firefox addon called "Movie Download Helper", which can extract stream-urls from a website. I visited the websites which offered livestreams, startet the stream and extracted the url. I highly reccomend you find a way to get livestream-urls yourself because they change from time to time.
    My idea was to use the extracted url and paste it into the url field in the mux basic settings. That worked fine but there was a catch.

    The offset-problem

    When I did my first recording I noticed that the timing was off by 30 minutes. It turned out that at the time German livestreams like ARD und ZDF were able to be delayed by 30 minutes on the website. For some reason programs like vlc played the stream at the current time but tvheadend started at the beginning of the stream, which was 30 minutes in the past. While looking for a workaround I looked at alternative stream urls and noticed that some urls had a dw=0 parameter added to the url. I added this parameter to my url and it worked! Tvheadend correctly used the end of the stream (current time). Don't ask me why, though...

    (If you are not familiar with url parameters: The first parameter is added to a url by adding a ? and subsequent parameters are added using & so you will find both strings ?dw=0 and &dw=0 in the urls.)

    The offset-problem again

    After one year with my iptv livestream the German channel ARD allowed their livestream to be delayed by up to 2 hours. This also caused my dw=0 parameter to stop working, I assume because they changed the fundamental service. This was a tough nut to crack. In the tvheadend forum I read the suggestion to pipe the stream through ffmpeg. So I installed the package tools.ffmpeg-tools and piped the stream through ffmpeg as follows:

    Code
    1. pipe:///storage/.kodi/addons/tools.ffmpeg-tools/bin/ffmpeg -loglevel fatal -re -i <STREAM_URL> -vcodec copy -acodec copy -metadata service_provider=Streams -metadata service_name=<CHANNEL_NAME> -mpegts_service_type advanced_codec_digital_sdtv -f mpegts pipe:1

    replace <STREAM_URL> and <CHANNEL_NAME> with your values.


    This solved my offset problem and also fixes issues when vlc is able to play a url but tvheadend is not. So I highly recommend this method.

    My config

    The following list contains the channel-name, the url I extracted from the website and the string I used in the url field of the mux-config