QtMultimedia record sound and save as MP3
-
Ok, I managed to to record sound as raw PCM data and play it back again using QAudioInput and QAudioOutput.
However I didn't manage (and can't find anything online) to save this data as MP3, WMA, etc. The example shown in the docs ("http://developer.qt.nokia.com/doc/qt-4.8/qaudioinput.html":http://developer.qt.nokia.com/doc/qt-4.8/qaudioinput.html) saves the data as PCM data. When I run QAudioDeviceInfo::supportedCodecs() it only returns the PCM codec.Is there any way to export or convert the pcm to MP3, WMA, WAV, etc?
Thanks
-
I've noticed this is possible with QMediaRecorder. However I have to process (spectrum analysis, etc) the data first, so I don't think QMediaRecorder is an option.
-
bq. Is there any way to export or convert the pcm to MP3, WMA, WAV, etc?
WAV is a specific PCM format. For MP3 and WMA, you need an audio codec which use the PCM data you have created. I don't know if Qt has some builtin codecs, but you can get a MP3 decoding library and just plug it in. Try "mpg123":http://www.mpg123.de/ for example.
-
Yes, as far as I know there are no MP3, etc codecs in Qt. But I don't really want to use external libraries, since it complicates things and I want to port my app to all kinds of systems. So I though if someone didn't write a few Qt classes to support these formats that I can just add to my app.
-
try looking at how VLC guys do this, maybe it would help. VLC is cross-platform and bundles it's own codecs.
-
Thanks, is VLC generic enough to use on mobile and embedded devices?
-
no idea. Probably yes.
-
Ok, thanks. I'll have a look into that.
-
Does anyone know if there are any plans from Qt's side to someday add additional codecs, or would it make Qt too specific (non-generic)?
-
I had my application doing the exact opposite of yours, which was reading AAC audio and process it in some way. I found a 3rd party library, tested it on the Mac, Windows, and Linux and used with Qt. Plus, there are lot of applications out there which need to run on dedicated devices, so I expect libraries compatible with these devices to exist.
If the trolls add a codec, it will be one already done by a third party, that will be tested and validated. Don't expect the Qt developers to reinvent the wheel.