Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Audio Recording
Forum Updated to NodeBB v4.3 + New Features

Audio Recording

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 3 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • NickVN Offline
    NickVN Offline
    NickV
    wrote on last edited by NickV
    #1

    I want to record my voice over microphone. I call a c++ function from qml to record my voice. I use AudioRecorder to record.
    The problem is that my phone always records mp4 files. I want another encoding, not mp4. For example mp3 or wav.
    My code is the following:

    audio = new QAudioRecorder(this);
    QAudioEncoderSettings audioSettings;
    audioSettings.setQuality(QMultimedia::HighQuality);
    audioSettings.setCodec("audio/raw");
    audioSettings.setSampleRate(96000);
    
    audio->setEncodingSettings(audioSettings);
    
    audio->setOutputLocation(QUrl::fromLocalFile("/mnt/sdcard/test.wav"));
    audio->record();
    

    The output file is test.wav.mp4.
    Any idea?

    D 1 Reply Last reply
    0
    • NickVN NickV

      I want to record my voice over microphone. I call a c++ function from qml to record my voice. I use AudioRecorder to record.
      The problem is that my phone always records mp4 files. I want another encoding, not mp4. For example mp3 or wav.
      My code is the following:

      audio = new QAudioRecorder(this);
      QAudioEncoderSettings audioSettings;
      audioSettings.setQuality(QMultimedia::HighQuality);
      audioSettings.setCodec("audio/raw");
      audioSettings.setSampleRate(96000);
      
      audio->setEncodingSettings(audioSettings);
      
      audio->setOutputLocation(QUrl::fromLocalFile("/mnt/sdcard/test.wav"));
      audio->record();
      

      The output file is test.wav.mp4.
      Any idea?

      D Offline
      D Offline
      DRoscoe
      wrote on last edited by DRoscoe
      #2

      @NickV What phone are you recording from? Your options will be limited by what's available on your hardware. Look at the following for information on how to obtain the available codecs for your device
      QAudioFormat

      1 Reply Last reply
      2
      • NickVN Offline
        NickVN Offline
        NickV
        wrote on last edited by
        #3

        The only available is audio/pcm.
        My phone is samsung core prime 2. I figured out that only mp4 i can record. But with QAudioEncoderSettings i set the lower quality in order to have small size files. So everything is ok. Thanks for your reply.

        1 Reply Last reply
        0
        • canellasC Offline
          canellasC Offline
          canellas
          wrote on last edited by canellas
          #4

          Hi!

          The 'QAudioRecorder::setEncodingSettings' method takes 3 parameters: 'const QAudioEncoderSettings & audio', 'const QVideoEncoderSettings & video', and 'const QString & container'.

          The codec you defined does not define the type of file that will recorded. This is done by the 'container' parameter.

          If you let it undefined, the OS will choose what ever it wants. My experience is that on iOS it chooses "wav", while on Android it chooses "mp4".

          So, I know 3 ways: you can set the value of 'container', and hope it works on your device; you can leave it to the OS, as I said above; you can examine the 'QStringList QAudioRecorder::supportedContainers() const', and choose one.

          Oh, the 'video' parameter I use 'QVideoEncoderSettings()' default constructor.

          Good luck!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved