2

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!

László Papp
  • 51,870
  • 39
  • 111
  • 135
Kevin Liu
  • 23
  • 3

2 Answers2

0

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
rene
  • 41,474
  • 78
  • 114
  • 152
László Papp
  • 51,870
  • 39
  • 111
  • 135
0

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];
    }
Pazel1374
  • 218
  • 3
  • 14