firsttris / plugin.video.sendtokodi

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

Recent youtube videos not playing #58

Open 7karathrace opened 2 years ago

7karathrace commented 2 years ago

Over last couple of weeks I've found increasing numbers of new youtube videos fail to play. e.g. https://www.youtube.com/watch?v=BBnomwpF_uY

2022-05-22 15:35:08.955 T:1954    ERROR <general>: CFileCache::Process - <https://rr4---sn-8pgbpohxqp5-cimk.googlevideo.com/videoplayback?expire=1653251706&ei=GkqKYqr_JMHl1g
bUmrPIBQ&ip=82.9.226.188&id=o-ABbW1c3Vuu7uILYy6rNH6AjJZYW4N24hdhujnvOAYUB4&itag=22&source=youtube&requiressl=yes&mh=EM&mm=31%2C29&mn=sn-8pgbpohxqp5-cimk%2Csn-aigzrnsl&ms=au%
2Crdu&mv=m&mvi=4&pl=23&initcwndbps=1615000&vprv=1&mime=video%2Fmp4&cnr=14&ratebypass=yes&dur=1346.060&lmt=1652929147929587&mt=1653229024&fvip=3&fexp=24001373%2C24007246&c=AN
DROID&txp=4432434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgFWNVIWoqLWWO--YsUP0MAcqWyUQyy909ZcO
ibdgJALcCIQDSjhmQEWJzq1Xqx1YXzoSIA2F40-f6um_PPcEujM9vcw%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAIZMs7fWgxza62V7_poXP05GqpsatayXnujcf
_dx73MQAiEAw1XfUrROCFUNssIVaq_KkRzpICcUuWV1Xl8PlsqYs-M%3D> source read didn't return any data before eof!

Kodi log: http://ix.io/3YmP

Same issue with yt-dlp or youtube-dl

nullket commented 2 years ago

I had one as well but forgot to remember the link. Thanks for providing a link. I will test it myself the coming week. Can you also please check it with YouTube dlp and the -f best option outside of the plugin?

I assume this is due to the fact that this plugin does not have support for input stream adaptive (individual sound and audio stream depending on your bandwidth). Currently we only get the „best“ combined (single/all in one) file which for YouTube is a 720p mp4 link but I assume that one might not be available (yet) for certain videos.

Enabling input stream adaptive is unfortunately a lot of work :/

As mentioned I will play around with your provided link to see what the matter might be. But the fix could actually take a bit as the Kodi input stream adaptive docs could be a bit better and it might take some time to understand what we need to do.

nullket commented 2 years ago

I just checked this. The link you provided works for me on kodi 19 with yt-dlp as the default resolver. Furthermore, the link also works with yt-dlp standalone.

I can not reproduce your issue.

Can you please make sure you use the plugin in v0.9.169 or above and test again? Which Kodi version are you using?

7karathrace commented 2 years ago

I included a kodi log:

2022-05-22 14:34:48.111 T:1828     INFO <general>: Starting Kodi (19.4 (19.4.0) Git:19.4-Matrix). Platform: Linux ARM 32-bit
2022-05-22 14:34:48.238 T:1828     INFO <general>: CAddonMgr::FindAddons: plugin.video.sendtokodi v0.9.167 installed

That was the newest version of sendtokodi when I created the issue. I can try again tonight when I'm back home.

I did wonder if was related to https://github.com/yt-dlp/yt-dlp/issues/3372

nullket commented 2 years ago

I included a kodi log:

Yep sorry, I was a bit to tired this morning to think of looking there..

I did wonder if was related to https://github.com/yt-dlp/yt-dlp/issues/3372

That might be the reason but now it is working for me and I hope for you as well. In any case the linked issue is another reason to implement input stream adaptive #34

7karathrace commented 2 years ago

I’ve tested with latest version and there’s still an issue.

Interestingly some failing videos (including the one linked in first post) are playing correctly today. But others fail in same way.

here is one that is currently failing: https://youtube.com/watch?v=zTZuD4fVutc&feature=share

nullket commented 2 years ago

As guessed, this it out of our hands. Even yt-dlp standalone does not work with the -f b flag (required for a single file stream as we do not support mixing an separate audio and video stream together yet). Please try all your failing videos with a standalone version of yt-dlp.

yt-dlp -f b https://www.youtube.com/watch?v=zTZuD4fVutc
[youtube] zTZuD4fVutc: Downloading webpage
[youtube] zTZuD4fVutc: Downloading android player API JSON
[info] zTZuD4fVutc: Downloading 1 format(s): 22
[download] Destination: I’m tired of winning (and it's awesome) [zTZuD4fVutc].mp4
[download]   0.9% of 32.81MiB at  3.04MiB/s ETA 00:10[download] Got server HTTP error: Downloaded 300215 bytes, expected 34405509 bytes. Retrying (attempt 1 of 10) ...

ERROR: Did not get any data blocks

I have the feeling that this issue is only on new videos. After a certain time the 720p all in one stream seems to get fixed on youtubes side and then the download/playback works again.

I think there is nothing we can do but implementing input stream adaptive. Unfortunately, that is not something you do in a couple of minutes.

7karathrace commented 2 years ago

Standalone yt-dlp is failing for me too. I agree that it appears new videos have the issue and after some time they work.

Using inputstream to mux separate audio/video streams would be great.

xxxLCxxx commented 2 years ago

This appears to be some sort of censorship, as “certain” videos are being held back MUCH longer than others in conversion. It's also odd that this should only affect one format, by the way. Note that there would be various solutions. 140+136 could be downloaded (and streamed) simultaneously as an alternative. yt-dlp already supports downloading multiple fragments at once (multithreaded). Since the audio is typically smaller than the video and it's not much of an issue to buffer it, this should work. Furthermore, alternative formats (like WEBM) work. Also one could fall-back to other resolutions (which also work). Currently only format 22 (1280x720 in x264) seems affected. This looks “artificial”, by design.

nullket commented 2 years ago

@xxxLCxxx thank you very for stopping by here and the clarification!

It's also odd that this should only affect one format, by the way

I assume that is just google not caring and not making extra hard. As far as I know the 720p is not really used by any official youtube app/website anymore, so they simply do not need it anymore themselves (but I might be wrong). Whatever it is, it is not in our hand.

supports downloading multiple fragments at once

Thanks for clarifying but the purpose of our little plugin here is to stream and not download and then play a local (muxed) file. I assume the time has come to implement DASH / input stream adaptive and use yt_dlp to get the individual streams.

I have already looked a bit into DASH but it will take some time to implement it here. Once our other issues concerning playlists are sorted out, I will focus on that. Help in any way is appreciated ;)

xxxLCxxx commented 2 years ago

Apologies for using the wrong language, as I see this mostly as the same (“streaming” being just “downloading” with throwing the data away). Format 22 is probably among the most downloaded. This problem only started recently and it overwhelmingly affects “certain content”. yt-dlp should be able to download/stream into sockets, which then can be used as input for ffmpeg, which then can mix them and stream/pipe the output to vlc or such. This should be implemented in yt-dlp best. I would not advise scriping such a construct.

pukkandan commented 1 year ago

If ffmpeg is acceptable as a dependency, the separate video+audio URLs can be passed to ffmpeg to get a single playable stream. There is no need to download and merge in separate steps. Eg: see what yt-dlp --downloader ffmpeg "URL" does

nullket commented 1 year ago

The multiple streams thing is actually not the problem anymore. Kodi is able to play and merge multiple streams (even for several qualities). The way to go is:

  1. find a robust way of getting those separate audio and video streams for different pages (if it would just be YouTube it would be a lot easier). I do have a rough prototype for this outside of the addon. Unfortunately all the different websites have different formats and we need a logic to process, sort and ignore them (something like yt-dlp does as well). Not all formats are supported, multiple mirrors etc.
  2. create a dash file which helps Kodi to understand the different kind of streams
  3. provide this file using a webserver to Kodi (that is how Kodi needs it)

See https://github.com/firsttris/plugin.video.sendtokodi/issues/34

Now all I need is time (this summer is a hot phase of my phd) or somebody helping to implement this without breaking everything and remaining also the functionality how it works now (for legacy python2, unsupported formats and stability reasons)