Question

I'm using QAudioRecorder in Qt to record a voice, here is the sample code.

audioRecorder = new QAudioRecorder;

QAudioEncoderSettings audioSettings;
audioSettings.setCodec("audio/amr"); //here's my question
audioSettings.setQuality(QMultimedia::HighQuality);

audioRecorder->setEncodingSettings(audioSettings);

audioRecorder->setOutputLocation(QUrl::fromLocalFile("test.amr"));
audioRecorder->record();

But I have no idea how to use the setCodec() function

void QAudioEncoderSettings::setCodec(const QString & codec)

How can find out which parameter (such as "audio/amr" or "audio/x-wav") I can use and their exact meanings? Thanks!

Was it helpful?

Solution

You could see the codec candidate in the source code for the different plugins.

  • GStreamer
    • audio/mpeg
    • audio/vorbis
    • audio/speex
    • audio/GSM
    • audio/PCM
    • audio/AMR
    • audio/AMR-WB
    • audio/FLAC

  • AudioCapture
    • audio/pcm

  • QNX
    • aac
    • raw

OTHER TIPS

You can call supportedAudioCodecs in the QMediaRecorder class to get list of supported codecs.

MWE:

    QAudioRecorder *recorder = new QAudioRecorder(this);
    QStringList codecs_list = recorder->supportedAudioCodecs();

    for( int i=0 ; i<codecs_list.count() ; i++ )
    {
        qDebug() << codecs_list[i];
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top