Closed Pithakote closed 4 months ago
This is because Youtube videos over 720p, might be 1080p, don't have audio. The audio for these videos is stored in a different URL. Play around with the YoutubeDlOptions and post the URLs into a web browser to see exactly how it works.
There are 2 ways around this. You could either process a URL twice, once getting the video URL and then another getting a low-resolution video(only using the audio), both being streamed into their own video players. You'd need YoutubeDlOptions something like "bestvideo[height<=?1440]" for video and "worst" for the audio.
The other way is doing pretty much the same but using "bestaudio" or "worstaudio" then using a Unity web request to stream the audio in. This method is more performant as you're not having to stream 2 video feeds in but requires a bit more work.
I needed to do this in my project, I started with the first option as a proof of concept then changed over to the second option to save bandwidth.
This is because Youtube videos over 720p, might be 1080p, don't have audio. The audio for these videos is stored in a different URL. Play around with the YoutubeDlOptions and post the URLs into a web browser to see exactly how it works.
There are 2 ways around this. You could either process a URL twice, once getting the video URL and then another getting a low-resolution video(only using the audio), both being streamed into their own video players. You'd need YoutubeDlOptions something like "bestvideo[height<=?1440]" for video and "worst" for the audio.
The other way is doing pretty much the same but using "bestaudio" or "worstaudio" then using a Unity web request to stream the audio in. This method is more performant as you're not having to stream 2 video feeds in but requires a bit more work.
I needed to do this in my project, I started with the first option as a proof of concept then changed over to the second option to save bandwidth.
Thanks for the information!
I made it work using the first method you mentioned on the same day i posted it 😅. I did not know about the second method. Also, could you tell me those keywords "bestaudio" / "worstaudio" "worst" etc, and where can I learn more about them?
Thanks!
Thanks for the information!
I made it work using the first method you mentioned on the same day i posted it 😅. I did not know about the second method. Also, could you tell me those keywords "bestaudio" / "worstaudio" "worst" etc, and where can I learn more about them?
Thanks!
No worries, glad you got it sorted.
You can find more info here and the keywords are located here.
What @jeffries7 is suggesting is correct. I wanted to avoid adding a "hacky" sample that uses two download urls, one for audio and another for video, because then I will be dealing with countless Github issues related to performance of desynchronized audio and video. Until there's a good way to solve it, I'll leave at that.
But loving the discussion! Please leave these technical hints for others to find, it come useful
hello,
I'm trying to make a paranomic 360 youtube video player which renders onto a texture for a skybox. everything works just fine but when it's using YoutubeDlOptions.Three60, the audio stops working and it only works with YoutubeDlOptions.Default mode.
This is a problem because I cannot use YoutubeDlOptions.Default because it stretched the texture on the top and the bottom of the skybox and has got some "cuts" in the video as well.
Can anyone help?
Thanks!