anrayliu / pyvidplayer2

Reliable, easy, and fast video playing in Python
MIT License
32 stars 7 forks source link

[feature request] Allow playback of videos that do not have an audio track #32

Closed GordonZed closed 1 month ago

GordonZed commented 1 month ago

I have to assume I'm not the only person who has tried to get video playing in Python with the end goal being digital signage. When video is uploaded to my web interface, ffmpeg re-encodes it, and removes the audio track, if present.

When I decided to give pyvidplayer2 a go, I realized I would have to include an audio track, because the audio handler throws an error without it ("Audio is empty. This may mean the file is corrupted or that the video does not contain any audio."). I've re-encoded my test file to add an empty AAC audio track, but it would be nice if either 1. if there isn't an audio track at all, to just ignore audio and decode the video, or 2. if that could be a silent error that gives a warning rather than an error that halts execution, because this little Pi Zero 2W's 512MB of RAM already has its work cut out for it, so not having to have an ALSA or PulseAudio daemon running at all would be the ideal.

I'm attempting to implement this myself, and if I come to a more graceful (as in "graceful degredation") implementation, I'll submit a PR.

Thanks for this library by the way. If I weren't working in the constraints of a very RAM-strapped SBC, it would be pretty much the easiest way to play some video in a Python project.

anrayliu commented 1 month ago

Hi, I have an update ready to be pushed that already adds support for silent videos. Unfortunately, I am quite busy at the moment so expect it to be available in about 2 weeks. Sorry for the inconvenience.

GordonZed commented 1 month ago

Good to hear! In the meantime, I've bodged a solution that works for my needs at the moment. If anything, I can push an update to my app using the new version when it's available.

anrayliu commented 1 month ago

Hey, I just released the update. In version 0.9.14, the video class should be able to automatically detect silent videos and generate silent tracks on the fly. In case the auto detection fails, you can also initialize the video class with no_audio=True to force generate silent audio. Cheers!

GordonZed commented 3 weeks ago

I did see that update, but thanks for taking the time to let me know. I ended up now using this in my project though (ended up just using subprocess.Popen() to call ffplay directly instead) 'cause both Pyglet and Pygame ended up being too much overhead to get smooth playback on the Pi Zero W. Will keep this project in mind for next time though, when I'm working on hardware with a little more room to breathe 👍