QMediaPlayer - modify audio on the fly

983 views Asked by At

I'm researching options for creating a simple video player. What I'd like to do, is to apply some audio processing (e.g. low pass filter for simplicity) while playing back the video. I've looked at Qt multimedia API, so here's my main question:

  • How could I edit the audio output of a QMediaPlayer? Do I need some lower level APIs?

Additionally, if some other technologies would suit this purpose better or provide better open source libraries, feel free to suggest. I have experience with C# as well.

1

There are 1 answers

0
VuVirt On BEST ANSWER

QMediaPlayer doesn't allow low-level access to the audio data. I'd suggest to you to use the QAudioOutput and QAudioDecoder classes for your purpose. The QAudioDecoder produces QAudioBuffer objects. You can access the data() of these objects, process it (modify it) and feed it to the QIODevice that is returned by the start() method of the QAudioOutput object. This will be the audio playback path of your player. For the video you'll still use a muted QMediaPlayer to decode the video frames from the same file and output them to a QAbstractVideoSurface. You'll then need an algorithm to sync the video and audio frames produced by the above two methods.