Help debugging IPTV streams
Added by Chris G about 2 years ago
Hello. I am trying to debug why my IPTV streams do not work.
I just get "client hung up" immediately after starting the stream... Sometimes I might see 1 frame of video.
Below is a screenshot of my debugging.
Here is the log
2022-10-26 18:31:50.606 http: 10.0.1.7: using ticket a3da9b96ae745c5e7c72bbadb502fcc4130b782f for /stream/service/74d6eba1e72ec5c3068f3ae853f10d62 2022-10-26 18:31:50.608 service: 2: IPTV/http://10.0.1.7:8001/play/Service01 si 0x7f680f7f50 weight 0 prio 11 error 0 (OK) 2022-10-26 18:31:50.608 subscription: 0005: "HTTP" subscribing to service "IPTV/http://10.0.1.7:8001/play/Service01", weight: 100, adapter: "IPTV #1", network: "IPTV", mux: "http://10.0.1.7:8001/play", provider: "FFmpeg", profile="pass", hostname="10.0.1.7", client="VLC/3.0.16 LibVLC/3.0.16" 2022-10-26 18:31:50.608 webui: Start streaming /stream/service/74d6eba1e72ec5c3068f3ae853f10d62?ticket=a3da9b96ae745c5e7c72bbadb502fcc4130b782f 2022-10-26 18:31:51.608 webui: Stop streaming /stream/service/74d6eba1e72ec5c3068f3ae853f10d62?ticket=a3da9b96ae745c5e7c72bbadb502fcc4130b782f, client hung up 2022-10-26 18:31:51.608 subscription: 0004: "HTTP" unsubscribing, hostname="10.0.1.7", client="VLC/3.0.16 LibVLC/3.0.16"
The stream is not the problem. If I play it directly in VLC it is flawless.
I am not interested in using the av library, or using pipe commands.
I would like to figure out the exact reason why these streams will not play.
My main system is a Ubuntu host with TVH inside a Docker container (linuxserver.io)
I experience the same results on my Raspberry Pi with native install.
Replies (13)
RE: Help debugging IPTV streams - Added by saen acro about 2 years ago
From where come from stream?
DVB, IPTV or VOD?
RE: Help debugging IPTV streams - Added by Chris G about 2 years ago
IPTV re-stream using this simple flask logic...
from flask import Flask, Response, redirect import requests app = Flask(__name__) @app.route("/play", methods=["GET"]) def play(): link = "https://a7b60a6853d843dd9105acfa8d6e74c7.mediatailor.us-east-1.amazonaws.com/v1/manifest/44f73ba4d03e9607dcd9bebdcb8494d86964f1d8/Samsung-gb_BeanoTV/dde16029-6152-4e66-a220-5974c536644e/2.m3u8" def stream(): try: with requests.get(link, stream=True) as response: for chunk in response.iter_content(chunk_size=1024): yield chunk except: print("DONE") #return redirect(link) return Response(stream()) if __name__ == "__main__": app.run(host="0.0.0.0", port=8001, debug=True)
TVH is the only client I have tried that has trouble playing the streams.
If I enable AV library, then it will work. But the AV lib is slow and buggy so I don't want to use it.
The original streams are 100% compatible with TVH. I know this because if I return a redirect instead of using the requests library, then it plays them.
I cant use redirects though because I need to keep track of which streams are being viewed.
EDIT: Added a real link so that you can try it yourself. The stream will work if its returned as a redirect, but not if its streamed.
RE: Help debugging IPTV streams - Added by Chris G about 2 years ago
Hello thanks for the reply.
I just built the latest master using the linuxserver.io docker image and it still doesn't work with the example given above.
EDIT: I think that link I gave is a bad example. You need a continuous stream to test but I cant give you mine.
RE: Help debugging IPTV streams - Added by Flole Systems about 2 years ago
Check using tcpdump or Wireshark to figure out if the client closes the connection for some reason as the log indicates. You can also use wget for example to "download" the stream from Tvheadend, it's very helpful when debugging as it's very verbose compared to VLC for example.
RE: Help debugging IPTV streams - Added by Flole Systems about 2 years ago
No it can't as it doesn't show information about the HTTP protocol and aborts playback if no valid video data is received....
RE: Help debugging IPTV streams - Added by Chris G about 2 years ago
If I use wget on the service (http://10.0.1.200:9981/play/ticket/stream/service/7f91e773910e858d58d0e640e4fc0e70?title=Service01%20%2F%20FFmpeg), wget downloads a few "K", then just sits there waiting for more. It never comes though because TVH has already disconnected from my flask app.
Here is the log:
2022-10-27 17:30:06.267 service: 12: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a2a892850 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 11: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a313a7790 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 10: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a2855b790 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 9: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a2bc3c790 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 8: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a2bc8d3d0 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 7: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a2bdc2a90 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 6: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a238f9550 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 5: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a3a660cd0 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 4: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a3a660b50 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 3: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a3a660910 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 2: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a3a660790 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 service: 1: Test/http://10.0.1.7:8001/play/Service01 si 0x7f7a3a6606d0 weight 0 prio 11 error 0 (OK) 2022-10-27 17:30:06.267 mpegts: http://10.0.1.7:8001/play in Test - tuning on IPTV #1 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 0000 (0) [20/0x7f7a39894020] 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 0001 (1) [16/0x7f7a39896aa0] 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 0010 (16) [20/0x7f7a41963570] 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 0011 (17) [20/0x7f7a41964a90] 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 0011 (17) [16/0x7f7a42d02ab0] 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - started 2022-10-27 17:30:06.268 tbl-eit: uk_freesat: grab started 2022-10-27 17:30:06.268 tbl-eit: uk_freesat_eit: grab started 2022-10-27 17:30:06.268 tbl-eit: uk_freeview: grab started 2022-10-27 17:30:06.268 tbl-eit: nz_freeview2: grab started 2022-10-27 17:30:06.268 tbl-eit: nz_freeview1: grab started 2022-10-27 17:30:06.268 tbl-eit: viasat_baltic: grab started 2022-10-27 17:30:06.268 tbl-eit: Bulsatcom_39E: grab started 2022-10-27 17:30:06.268 tbl-eit: uk_cable_virgin: grab started 2022-10-27 17:30:06.268 tbl-eit: eit: grab started 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 1FFB (8187) [20/0x7f7a3a8ae020] 2022-10-27 17:30:06.268 tbl-eit: mgt: installed table handlers 2022-10-27 17:30:06.268 psip: psip: grab started 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 1000 (4096) [8/0x7f7a236f2f10] 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 0100 (256) [8/0x7f7a236f2f10] 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 0101 (257) [8/0x7f7a236f2f10] 2022-10-27 17:30:06.268 mpegts: http://10.0.1.7:8001/play in Test - open PID 1000 (4096) [16/0x7f7a3a8af560] 2022-10-27 17:30:06.268 subscription: 004D: "HTTP" subscribing to service "Test/http://10.0.1.7:8001/play/Service01", weight: 100, adapter: "IPTV #1", network: "Test", mux: "http://10.0.1.7:8001/play", provider: "FFmpeg", profile="pass", hostname="10.0.1.7", client="Wget/1.20.3 (linux-gnu)" 2022-10-27 17:30:07.907 service: Test/http://10.0.1.7:8001/play/Service01: Status changed to [Hardware input] 2022-10-27 17:30:07.907 service: Test/http://10.0.1.7:8001/play/Service01: Status changed to [Hardware input] [Input on service] 2022-10-27 17:30:07.907 service: Test/http://10.0.1.7:8001/play/Service01: Status changed to [Hardware input] [Input on service] [Demuxed packets] 2022-10-27 17:30:07.907 service: Test/http://10.0.1.7:8001/play/Service01: Status changed to [Hardware input] [Input on service] [Demuxed packets] [Reassembled packets] 2022-10-27 17:30:07.907 webui: Start streaming /play/ticket/stream/service/7f91e773910e858d58d0e640e4fc0e70?title=Service01%20%2F%20FFmpeg 2022-10-27 17:30:07.907 tbl-base: sdt: onid FF01 (65281) tsid 0001 (1) 2022-10-27 17:30:07.907 tbl-base: sdt: mux http://10.0.1.7:8001/play in Test 2022-10-27 17:30:07.907 tbl-base: sdt: sid 0001 (1) running 4 free_ca 0 2022-10-27 17:30:07.907 tbl-base: pat: 0x7f7a23e3d980: tsid 0001 (1) 2022-10-27 17:30:07.907 tbl-base: pat: sid 0001 (1) on pid 1000 (4096) 2022-10-27 17:30:07.907 tbl-base: pmt: sid 0001 (1) 2022-10-27 17:30:07.907 tbl-base: pmt: pcr_pid 0100 2022-10-27 17:30:07.907 tbl-base: pmt: pid 0100 estype 27 2022-10-27 17:30:07.907 tbl-base: pmt: type H264 position 0 2022-10-27 17:30:07.907 tbl-base: pmt: pid 0101 estype 15 2022-10-27 17:30:07.907 tbl-base: pmt: type AAC position 0 2022-10-27 17:30:38.893 webui: Stop streaming /play/ticket/stream/service/7f91e773910e858d58d0e640e4fc0e70?title=Service01%20%2F%20FFmpeg, client hung up 2022-10-27 17:30:38.893 subscription: 004D: "HTTP" unsubscribing, hostname="10.0.1.7", client="Wget/1.20.3 (linux-gnu)" 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 1000 (4096) [16/0x7f7a3a8af560] 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 1000 (4096) [8/0x7f7a236f2f10] 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 0100 (256) [8/0x7f7a236f2f10] 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 0101 (257) [8/0x7f7a236f2f10] 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - stopping mux 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 0000 (0) [20/0x7f7a39894020] 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 0001 (1) [16/0x7f7a39896aa0] 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 0010 (16) [20/0x7f7a41963570] 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 0011 (17) [20/0x7f7a41964a90] 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 0011 (17) [16/0x7f7a42d02ab0] 2022-10-27 17:30:38.893 mpegts: http://10.0.1.7:8001/play in Test - close PID 1FFB (8187) [20/0x7f7a3a8ae020] 2022-10-27 17:30:38.894 epggrab: grab done for http://10.0.1.7:8001/play in Test (stolen) 2022-10-27 17:30:38.894 psip: Calling _psip_stop
I can see that it is TVH that disconnects because the python generator is exited by flask when a client disconnects. Using prints I can see that it happens immediately after starting.
If I enable the av library in TVH, then the stream will play... But I shouldn't have to enable the av library because the stream is already compatible... I'm just restreaming it.
The fact I am getting a few K with wget and sometimes I see a single frame or two in VLC also suggests the stream is compatible. It just decides to disconnect right away for whatever reason.
RE: Help debugging IPTV streams - Added by Flole Systems about 2 years ago
Then you need to investigate why it disconnects if you're sure that it's Tvheadend that does the disconnection.
RE: Help debugging IPTV streams - Added by Chris G about 2 years ago
Perhaps I am wrong, but that's what I am here for. I have been tinkering with this for months.
I was hoping I could get TVH to somehow tell me why it closes. And why the av lib doesn't close.
It could well be something to do with my app... perhaps it is out of spec somehow?
Considering TVH is the only "player" I have tried that doesn't like my streams, I'd like to think it was an issue with TVH.
I've tried web browsers, VLC, FFMpeg, Plex... Only TVH gives me problems.
RE: Help debugging IPTV streams - Added by Flole Systems about 2 years ago
All active developers that know the code well have left. You will have to figure it out yourself. Go through the code, figure out the code path it takes and so on
RE: Help debugging IPTV streams - Added by Chris G about 2 years ago
Right, that's beyond my skill level unfortunately.
Good news though, I was able to get it working by switching from the built-in flask server to waitress. I wish I tried this a long time ago!
I still think there is a "problem" with TVH... its too fussy compared to other software I have tried. Maybe its super strict with standards?
RE: Help debugging IPTV streams - Added by Flole Systems about 2 years ago
Tvheadend doesn't really use libraries like for example curl to receive a stream, instead there is a HTTP client implemented which is very strict and doesn't really allow protocol violations and sometimes doesn't even allow everything the protocol specifies/violates the protocol itself. PRs with improvements are welcome