fe80Grau / ytdlp2STRM

A little script to serve Youtube / Twitch / Crunchyroll videos without storage it. Uses yt-dlp HTTP data throught Flask and dynamic URLs. We can use this dynamic URLs to set STRM files.
https://github.com/fe80Grau/ytdlp2STRM
MIT License
173 stars 15 forks source link

Higer quality videos #29

Open NaturalDevCR opened 5 months ago

NaturalDevCR commented 5 months ago

All videos from youtube have at most 720p quality... is there a way to allow higer resolutions?

fe80Grau commented 5 months ago

Hello, for ytdlp2STRM to work I must obtain a single URL with the multiplexed media, that is, the video and audio track in a single "file". I have been testing with the command yt-dlp bestvideo+bestaudio/best ..., The problem with this is that it returns two urls, one for video and one for audio... My first intention was for flask to redirect the local url generated in strm to M3U content and with this, set the video and audio stream tracks separately with I hope that VLC will reproduce it. But it has not worked or I have not known how to do it correctly.

The structure I was testing for the M3U is:

#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1280000
https://video-stream-url
#EXT-X-STREAM-INF:BANDWIDTH=128000
https://audio-stream-url

At the moment the only way for it to work correctly is with the 'best' option for yt-dlp and the URL obtained with the multiplexed video+audio is mostly 720p. I can work with the 'download' option of ytdlp2STRM to process the files once downloaded and serve the stream obtained by ffmpeg while the multiplexing is carried out, but it would not be as fast as the redirect mode since it must first completely download the audio tracks and video.

MyJellyfin commented 1 month ago

yeh, most of the videos are stuck at 720p, Hope you(@fe80Grau) can come up with a solution. Btw Thanks for this awesome project

skijbal commented 2 weeks ago

I was just about to ask about video resolutions myself. Glad I found this. I really enjoy this project.

fe80Grau commented 2 weeks ago

Hello, I know this is a highly anticipated feature for this project; however, it is quite challenging to make it as functional as a simple redirection. The options provided by yt-dlp (and the YouTube endpoints) only offer up to 720p quality with video and audio through a single thread, and the direct method essentially makes a 301 redirect to this thread.

To achieve the highest quality, it requires the parallel streaming of audio and video streams separately, then remuxing them in real-time and serving them.

WE ARE IN LUCK! I have gotten it to work with this logic, and you can try it out in the latest commit I have published by setting the bridge method for YouTube. Simply pull the project or download the latest commit and try it. Then, if you want to test it faster, you can manually edit an existing .strm file and replace /direct/ with /bridge/. With this and the new version, it will serve the highest available quality for the video in question.

Note that it is not perfect at all; navigation is not functional as it is extremely slow. The current navigation method with the bridge method becomes almost maddeningly slow, so I do not recommend using time navigation for videos set as bridge. I will continue investigating and testing with the hope of getting it to work sooner or later.