firsttris / plugin.video.sendtokodi

:tv: plays various stream sites on kodi using youtube-dl
MIT License
125 stars 28 forks source link

Peertube streams are only partially loaded #86

Open stemy2 opened 1 year ago

stemy2 commented 1 year ago

Describe the bug When i ask Sendtokodi to load a peertube stream, i have a video way shorter that it should be, because the duration detected by kodi is not the real video duration, making the video stop too early.

To Reproduce One of the videos:https://skeptikon.fr/w/jqvXupkVUVzJDwEToh85bx

Expected behavior The video is entirely extracted.

Kodi and sendtokodi version (please complete the following information):

Provide a Kodi log IMG_20221229_232152

Screenshots

Additional context I tried with yt-dlp, and it had to retry because of the connection has been reset. It may be a good clue.

nullket commented 1 year ago

I did some quick tests and your site is actually a good corner case of where again ytdlp/the page is not very consistent.

Firstly, I assume in the addon settings under "adaptive" the setting "use original manifest" is turned off? I have mine usually turned on as it makes a lot of other pages (that I use) work. With the feature turned on I do not get your link working at all (see below for the explanation).

The issue is that nowadays more and more websites use fragmented streams where there is no such thing as a "one file stream". Usually multiple streams (for audio, video, multiple qualities, languages etc.) get mixed together on the end device. Interestingly the page you provided uses this technique but there are streams which contains audio and video on the same time. So those could be seen as "one file stream" while they are part of the adaptive streaming concept. With the "use original manifest" setting turned off we let ytdlp search for the best "one file stream" which in that case is one of the adaptive streams (which is not the most common case for other streaming sites) containing both audio and video. Unfortunately, the correct duration is not within this stream and usually this would not needed as this particular stream is just one stream of many and part of the adaptive streaming technique which usually relies on a "manifest". This manifest declares all meta infos (like duration, URLs on where to find the fragmented streams etc.). So kodi just guesses the wrong duration (not our or anyone's fault).

If you turn the setting on, the plugin tries to find the manifest file and actually enable adaptive streaming (where you can choose qualities, languages etc. on the fly within the regular kodi gui). Unfortunately, your provided website either hides the manifest or the ytdlp extractor of that page simply does not provide it. In that case we usually fallback to our way of trying to find the best "one file stream". It seems like we do it a bit different than ytdlp itself and simply find not suitable stream as they are in fact all part of the adpative streaming technique.

TL;DR: Building custom HLS/DASH manifests is required for this page to work correct. This is tracked here https://github.com/firsttris/plugin.video.sendtokodi/issues/34

stemy2 commented 1 year ago

So do we have to wait until the website maintainer implement a correct manifest ?

nullket commented 1 year ago

Websites sometimes simply hide the manifest (on purpose or not). In that case sendtokodi must create a manifest itself based on the found streams and provide that custom manifest to kodi. This is not implemented yet and basically tracked in the issue above. The reason it is not implemented yet is that there many exceptions (different implementations for different websites) and a special way on how this manifest must be provided to kodi (via a webserver).