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. record audio in ios and save as mpeg
Forum Updated to NodeBB v4.3 + New Features

record audio in ios and save as mpeg

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 140 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.
  • V Offline
    V Offline
    vudangkhoa2906
    wrote on last edited by
    #1

    Hi guys, I'm trying to implement the voice message feature in my app.
    I have this issue. When I record the audio, the output file is of type .wav, which is really large (~1MB for only a few seconds)

    here is my code for the recording part:

        mAudioRecorder->setAudioInput(mAudioRecorder->defaultAudioInput());
        QAudioEncoderSettings mAudioEncoderSettings;
        mAudioEncoderSettings.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
        mAudioEncoderSettings.setChannelCount(1);
        mAudioEncoderSettings.setCodec("audio/pcm"); // this is the only supported codec for iOS
        mAudioEncoderSettings.setSampleRate(16000);
        mAudioEncoderSettings.setBitRate(16000);
        mAudioRecorder->setEncodingSettings(mAudioEncoderSettings);
        mAudioRecorder->record();
    

    after calling the

        mAudioRecorder->stop();
    

    method, I read the content of the saved audio:

                QFile file;
                file.setFileName(path.toLocalFile()); // this is a .wav file
                if (!file.open(QIODevice::ReadOnly)) {
                    return;
                }
    
                QByteArray fileContent(file.readAll());
                qDebug() <<  fileContent.size();
                if (fileContent.size() > 300 * 1024) {
                    qDebug() <<  error file content out of limit";
                }
    

    I only want the file to be 1MB the largest. is there anyway I can convert the .wav to .mp4/aac/m4a output (which are smaller)?

    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