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. Recording Audio Using QtAudioRecorder
Forum Updated to NodeBB v4.3 + New Features

Recording Audio Using QtAudioRecorder

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 3.0k 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.
  • C Offline
    C Offline
    Colirbi
    wrote on last edited by
    #1

    Hi everyone,

    im trying to use the QtAudioRecorder to record some simple soundfiles. But I've discovered a few problems.

    First if I'm trying to use it like in the example it keeps showing an error like:

    "Could not create a media muxer element: "" "

    It's always the same error even if i switch the codec.

    However there's a workaround for that error. It dissapears when im not using
    @audioSettings.setCodec("audio/wav");@

    If i dont use the codec im able to take up to 3 records stored correctly in a .wav file (Sometimes i can take only 1 record, then again it's 2 or 3... I can't discover any regularity in it). But then the programm freezes when I'm using:
    @audioRecorder->stop();@

    My Code:
    @
    QAudioRecorder *audioRecorder; //Class member

    audioRecorder = new QAudioRecorder(this);

    audioRecorder->setAudioInput(audioRecorder->defaultAudioInput());
    QAudioEncoderSettings audioSettings;
    audioSettings.setCodec("audio/wav");
    audioSettings.setSampleRate(16000);
    audioSettings.setBitRate(32);
    audioSettings.setQuality(QMultimedia::HighQuality);
    audioSettings.setEncodingMode(QMultimedia::ConstantQualityEncoding);
    audioRecorder->setEncodingSettings(audioSettings);
    audioRecorder->setOutputLocation(QUrl::fromLocalFile("Test.wav"));

    //start Recording
    if (audioRecorder->state() == QMediaRecorder::StoppedState)
    {
    audioRecorder->record();
    }

    //stop Recording

    if (audioRecorder->state() == QMediaRecorder::RecordingState)
    {
    audioRecorder->stop();
    }
    @

    My OS is Debian 7.

    Any help is appreciated! Thanks in advance.

    Lucas

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pbouda
      wrote on last edited by pbouda
      #2

      This post is quite old, but I had a similar problem and solved it, so here is what I did. The problem was that I had to define both the codec and the container. The latter is necessary to create the muxer element, and the former has to be a string as defined in the Qt code (so I had to use "audio/PCM"; it did not work with "audio/wav" or "audio/pcm"):

      audioSettings.setCodec("audio/PCM");
      ...
      audioRecorder->setContainerFormat("wav");
      

      I could then record into a WAV file.

      Peter

      http://www.peterbouda.eu

      1 Reply Last reply
      1
      • sonichyS Offline
        sonichyS Offline
        sonichy
        wrote on last edited by
        #3

        Absolutely!

        https://github.com/sonichy

        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