Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Multimedia
  4. Changing Audio Sample Rate with QMediaRecord
Forum Updated to NodeBB v4.3 + New Features

Changing Audio Sample Rate with QMediaRecord

Scheduled Pinned Locked Moved Unsolved Qt Multimedia
3 Posts 2 Posters 623 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.
  • L Offline
    L Offline
    lightshade
    wrote on last edited by
    #1

    Dear ANYONE that can help me,

    I've been racking my brain and fighting with this Library trying to record audio with 1 channel and 16000 hz so that I can send it through an API. ive tried EVERYTHING. when i use recorder.audioChannelCount(); and recorder.audioSampleRate(); they are both correct but when I look at the details of the .wav file and when I try sending the file both say my sample rate is 48000hz with 2 channels. any help would be greatly appreciated!

    void AudioHandler::startRecording(const QString &outputFile)
    {
        recorder.setQuality(QMediaRecorder::HighQuality);
    
        QString projectDir = QDir(QCoreApplication::applicationDirPath()).absolutePath();
        QString filePath = QDir(projectDir).filePath(outputFile);
    
        recorder.setOutputLocation(QUrl::fromLocalFile(filePath));
    
        QMediaFormat format;
        format.setFileFormat(QMediaFormat::Wave);
    
        recorder.setMediaFormat(format);
    
        recorder.setAudioSampleRate(16000);
        recorder.setAudioChannelCount(1);
    
        recorder.record();
    
        qDebug() << "Recording started with sample rate" << recorder.audioSampleRate();
        qDebug() << "Recording started with channel count" << recorder.audioChannelCount();
    }
    
    
    void AudioHandler::stopRecording()
    {
        recorder.stop();
    }
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      What's your OS and Qt version?
      If you are using Qt6 with ffmpeg backend, there had been this issue in ffmpeg plugin.
      It is fixed now and should have been merged in the upcoming 6.8.3/6.9.0 release.

      1 Reply Last reply
      1
      • L Offline
        L Offline
        lightshade
        wrote on last edited by
        #3

        im on Windows with version 6.8.2

        Thanks for letting me know! I figured out another work around so for now I should be good!

        1 Reply Last reply
        0
        • Nhan NguyenN Nhan Nguyen moved this topic from General and Desktop on

        • Login

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