I was fiddling around with my IPTV setup for some days now. I found a lot of helpful information in this thread. Especially the FFmpeg parameters provided by Troy Boy helped a lot.
Here are the full commands I'm using:
Adapt the paths according to your setup.
Download your m3u file:
wget -O /tvheadend/config/iptv.m3u http://path.to.your.m3u
If the file has Windows line breaks (CRLF), convert it to Linux line breaks (LF):
dos2unix /tvheadend/config/iptv.m3u
Insert the pipe command to every line starting with `
http://`:
sed -i 's#^http://.*#pipe:///usr/bin/ffmpeg -reconnect 1 -reconnect_on_network_error 1 -reconnect_on_http_error 1 -reconnect_streamed 1 -reconnect_delay_max 4294 -fflags -nobuffer -err_detect ignore_err -i & -c copy -map 0 -f mpegts -tune zerolatency pipe:1#' /tvheadend/config/iptv.m3u
The FFmpeg command is based on the suggestion made by Troy Boy.
I added `-map 0`, such that every audio and subtitle stream is piped, if multiple are available.
I added `-reconnect_on_network_error 1 -reconnect_on_http_error 1 `, which force FFmpeg to reconnect when a TCP or HTTP error is received. For instance, my provider sometimes gives HTTP 404 errors.
Further, I increased `reconnect_delay_max` to the max value of 4.294 seconds. It determines how long FFmpeg tries to open the stream when an error occurs. Sadly, in some scenarios, even this can be too low. My IPTV provider seems to start streams on demand, meaning if nobody is watching them the stream is "sleeping". This often takes 10-20s. In this case, I have to start the stream a second time. But even with FFmpeg, this problem cannot be solved at the moment, due to the relatively low limit of `reconnect_delay_max`.
In any case, these parameters gave me the best experience. I use Kodi, Emby, and Jellyfin as clients.
EDIT:
I removed the following parameters because they made the audio become async after a while. I guess because the video FPS isn't determined correctly. I didn't notice any significant change in the stream start-up time.
`-probesize 1000k -analyzeduration 0 -fpsprobesize 0`