anrayliu / pyvidplayer2

Reliable, easy, and fast video playing in Python
MIT License
33 stars 10 forks source link

Compatibility with Audio Tracks? (Specifically YouTube) #45

Open Kekulism opened 2 weeks ago

Kekulism commented 2 weeks ago

My last issue got worked out fine (thank you for that by the way), but now I've run into a more pressing issue relating to streaming YouTube videos. I've recently noticed that some channels on YouTube have been given access to add multiple audio tracks to their videos for dubbing in different languages. This is a great feature, but it seems to be causing issues with streaming these videos in pyvidplayer2. When I tried putting this video, for example, in the program, it played the video in some other language I didn't recognize by default.

NVIDIA_Share_hqI30kHvI9

Since audio track selection and switching are already implemented for local videos, it would be really helpful to have that functionality implemented for YouTube video streaming as well.

anrayliu commented 2 weeks ago

Thanks for telling me, I didn't know Youtube had this feature. Luckily, this is an easy problem to solve, but you'll have to wait a few days because I am quite busy right now. As a side note, how are you liking the library? Have you tried with local videos? Just asking for feedback.

Kekulism commented 2 weeks ago

I haven't tried audio track switching yet, but the library is fantastic and I really appreciate that it exists. For my purposes it's great, I just gotta get better at programming so I can utilize it efficiently

Kekulism commented 2 weeks ago

While I'm at it, I'm having a different issue related to audio, I want to see if I can specify a specific audio device for the videos to play on, but I'm not quite sure how to do that. Is there a feature for that?

anrayliu commented 2 weeks ago

I actually did have someone add a device selector some time ago, but it's only for the backend. I will look into making it available to users.

Kekulism commented 1 week ago

One more thing, sorry I don't mean to give you a bunch of work to add to your pile but a bit ago you said that you would look into updating the VideoPlayer class to work better with the rest of the code. Whenever you get the time to do that, and if it's possible, could you look into adding support for the other graphics libraries in the VideoPlayer class? I'm thinking I might wanna switch over to Pyglet or a different alternative so that my project works better with async code, getting a lot of headaches related to not having async in my project

anrayliu commented 1 week ago

Unfortunately, this won't be a feature. I'm not proficient enough in Pyglet (or any other graphics library) to recreate the videoplayer UI, and learning would take too much time. If all you need is the queue system, you can probably take a look at the source code and create one yourself pretty quickly. But can I ask what problems you're having with Pygame that you think switching would help with?

Kekulism commented 1 week ago

Nevermind, I figured out a good way around the headaches I was describing. I was trying to find a way for my Pygame code to be able to run a separate async function that was able to handle the queueing of new videos into the VideoPlayer class. That way the currently playing video wouldn't stutter visually when the program loaded the queued video. I got that working, now it queues in the background with no lag, which is fantastic for my purposes.

Still trying to get some other issues sorted out with YT-DLP though, it seems like all YouTube videos with enhanced premium bitrates don't properly play their video at all (but they still play their audio) due to some download issues, and sometimes they'll even crash the Pygame window (but the audio will still play). Right now I'm trying to see if I can use a YT-DLP conf file to solve that issue with the downloads. I feel like this isn't an issue with pyvidplayer2 necessarily, so I wont ask more of you than I already have

anrayliu commented 1 week ago

it seems like all YouTube videos with enhanced premium bitrates don't properly play their video at all (but they still play their audio)

This is mostly likely because the program crashed but pyaudio is still playing the audio in a thread. If this is annoying, you can use the use_pygame_audio=True parameter instead of pyaudio, which will close whenever the program does as well.

As for the actual issue, I don't even have premium, so yeah I won't be of much help there.

anrayliu commented 3 days ago

Hey sorry for the late update, but v0.9.24 is now published and contains the features you have requested. Refer to preferred_language_demo.py and audio_devices_demo.py in the examples folder for instructions. Let me know if you encounter any bugs or issues. I'll leave this thread open for a little while until you confirm everything has been resolved. Cheers!