QAudioRecorder and output file name.



  • 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.



  • bump anyone?



  • bump........................


  • Moderators

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

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



  • 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 :(


  • Moderators

    "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.



  • 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.


  • Moderators

    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.



  • 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.


  • Moderators

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.