Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAudioRecorder and output file name.

QAudioRecorder and output file name.

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 5.4k Views 1 Watching
  • 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.
  • O Offline
    O Offline
    Overflowz
    wrote on last edited by
    #1

    Hi, I'm confused by QAudioRecorder class. I'm trying to record audio, but when I'm saving file, extension are automatically generated (in my case .WAV). isn't there any way to avoid this?

    [code]
    // setup audio recording.
    this->audioRecorder = new QAudioRecorder(this);

    QStringList codecList = this->audioRecorder->supportedAudioCodecs();
    if(!codecList.isEmpty())
    {
        // save audio codec.
        this->audioCodec = codecList[0];
    
        // configure settings.
        this->audioSettings.setCodec(this->audioCodec);
        this->audioSettings.setQuality(QMultimedia::HighQuality);
        this->audioRecorder->setEncodingSettings(this->audioSettings);
    
        this->audioRecorder->setContainerFormat("mp3");
        this->audioRecorder->setOutputLocation(QUrl::fromLocalFile(this->savePath + "/test/capture.mp3"));
        this->audioRecorder->record();
    }
    

    [/code]

    in this case, file is saved as "capture.mp3.wav". how to avoid this anyone please?

    Regards.

    1 Reply Last reply
    0
    • O Offline
      O Offline
      Overflowz
      wrote on last edited by
      #2

      bump anyone?

      1 Reply Last reply
      0
      • O Offline
        O Offline
        Overflowz
        wrote on last edited by
        #3

        bump........................

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          You told the recorder to use codecList[ 0]. What is codecList[ 0]?

          Please be patient and don't bump within the same day.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • O Offline
            O Offline
            Overflowz
            wrote on last edited by
            #5

            I'm not bumping at same day, I'm waiting 24h (if i remember correctly cause I'm having really crazy graph IRL).
            this is call to codecList..
            [code] QStringList codecList = this->audioRecorder->supportedAudioCodecs();[/code]

            it's "audio/pcm" on Windows.

            EDIT: sorry for bumps, I need it really much :(

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              "PCM" stands for Pulse-Code Modulation. This codec is used to produce WAV files, not MP3 files.

              Use the "audio/mpeg" codec to create MP3 files. Check audioRecorder->supportedAudioCodecs() to see if this codec is supported. If not, you'll need to use a 3rd-party converter to change your WAV file into an MP3 file.

              Also, MP3 files do not usually use containers. (In contrast, audio that is encoded using the Vorbis codec are usually stored in an Ogg container. See http://en.wikipedia.org/wiki/Digital_container_format#Multimedia_container_formats ).

              Choose the raw container to store MP3 files. Check the return value of audioRecorder->supportedAudioContainers() for the exact name.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              1
              • O Offline
                O Offline
                Overflowz
                wrote on last edited by
                #7

                Hi, thanks for the reply. supportedAudioCodecs() only returns "audio/pcm" in list, nothing else. The only problem I'm facing is that, I don't want that extension should be WAV. I'm trying to change the extension only.. when I specify the path of output, it automatically adds the .wav at the end, isn't there any way to force to not add the WAV at the end?

                Excuses for my English skills.
                Regards.

                1 Reply Last reply
                0
                • JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #8

                  Hi,

                  Your English is fine. I can understand you. :)

                  Yes, it automatically adds ".wav" to your filename. You can't stop it, but you can use "QFile":http://qt-project.org/doc/qt-5/QFile.html to rename your file afterwards.

                  What extension do you want?

                  "audio/pcm" does not produce MP3 files. "audio/pcm" produces WAV files.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    Overflowz
                    wrote on last edited by
                    #9

                    Just wanted any raw extension like for temporary use. I'll use QFile afterwards.

                    Thank you for your time!
                    Regards.

                    offtopic: My brain is just overflowed, doing a lot of stuff, I don't know why I don't get the QFile idea before hehe.

                    1 Reply Last reply
                    0
                    • JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote on last edited by
                      #10

                      Hehe, you're welcome! I'm glad you have a solution now. Happy coding!

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      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