Not able to retrieve an Audio object after Player is created
Hello,
I've been using this module quite a bit and it has been very useful so far. I am having difficulties though when it comes to work on the Audio.
More specifically, I am trying to get the audio from an RTP stream in order to detect any silences. What would be the best method to get an Audio Object once the Mediaplayer instance created ?
Thank you so much !
oDev
+1, Also tried using ff_opts = {"af":"silencedetect"} It seems the filter isn't taken in account.
It works perfectly though on a terminal using the commande: ffplay streamInput -af "silencedetect"
(video filters works perfectly on ffpyplayer. Have to use the following syntax: ff_opts = {"vf":[filter]}) Thank you !
oDev
Sorry, I started to respond but then left it in drafts.
What do you mean by "trying to get"? Do you mean you're trying to get the actual raw audio data? If that's the case, I'm afraid you have your work cut out for you. Originally, I needed a video player for our lab so that we could read and write actual video frames - that's why I started working on this project. But audio was not something that I really needed, so I didn't spend too much time on it beyond the simple port.
You'll notice that there's a video writer class but it doesn't support writing audio. That's kinda situation we're in. Keep in mind that this is a port of ffplay, which wasn't originally meant to be called from an api like we do. Also, getting audio to work right is a lot more sensitive because there's so many sync issues as opposed to video which is very simple. So getting audio to work properly would be a more difficult task and you'd need someone with experience in this field, which isn't me.
All that is just to say that support for audio beyond playing is not really present. Still, if you look at the place where audio is being passed to the audio device, it should be pretty simple to modify it so that it calls sdl_audio_callback_xxx which instead of the default sdl_audio_callback, is some python function passed by the user. The only issue is that sdl_audio_callback_xxx will need to get the timing right, make sure it still ticks the clock and so on, basically everything sdl_audio_callback does. It'll also have to add a audio_open_xxx instead of audio_open to make sure the audio is written with the correct format.
Perhaps it's simple to do, but currently it is not present.
Thank you for your answer ! This is very helpful,
My ultimate goal is to "detect" if the audio of a stream opened by Mediaplayer("rtp://x.x.x.x") is present or not. I might also have multiple RTP streams opened. I will then have to find out how to associate each stream with an Audio object I can work with.