Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQt6 QMediaRecorder recording no sound
Forum Updated to NodeBB v4.3 + New Features

PyQt6 QMediaRecorder recording no sound

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 617 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.
  • A Offline
    A Offline
    AB-Stromer
    wrote on last edited by
    #1

    I'm coding with Python 3.11 in Linux, PyQt6, and want to record audio to file. Using QMediaRecorder. My script writes an audio file m4a format to disk, but no sound is recorded. Basically microphone device works on this PC, have tested with other programs.

    What am I doing wrong?

    Here is my code:

    self.session = QMediaCaptureSession()
    self.audioInput = QAudioInput()
    self.session.setAudioInput(self.audioInput)
    self.recorder = QtMultimedia.QMediaRecorder()
    self.session.setRecorder(self.recorder)
    self.recorder.setOutputLocation(QUrl.fromLocalFile("/home/axel/Development/aiAudioDoc_files/aiAudioDoc02"))
    
    
    def ........
        self.recorder.setQuality(QtMultimedia.QMediaRecorder.Quality(3))
        self.audioInput.setVolume(80/100)
        self.recorder.record()
    
    SGaistS 1 Reply Last reply
    0
    • A AB-Stromer

      I'm coding with Python 3.11 in Linux, PyQt6, and want to record audio to file. Using QMediaRecorder. My script writes an audio file m4a format to disk, but no sound is recorded. Basically microphone device works on this PC, have tested with other programs.

      What am I doing wrong?

      Here is my code:

      self.session = QMediaCaptureSession()
      self.audioInput = QAudioInput()
      self.session.setAudioInput(self.audioInput)
      self.recorder = QtMultimedia.QMediaRecorder()
      self.session.setRecorder(self.recorder)
      self.recorder.setOutputLocation(QUrl.fromLocalFile("/home/axel/Development/aiAudioDoc_files/aiAudioDoc02"))
      
      
      def ........
          self.recorder.setQuality(QtMultimedia.QMediaRecorder.Quality(3))
          self.audioInput.setVolume(80/100)
          self.recorder.record()
      
      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      I haven't used the module yet but, what do you get from QMediaDevices with regard to audio inputs ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        I haven't used the module yet but, what do you get from QMediaDevices with regard to audio inputs ?

        A Offline
        A Offline
        AB-Stromer
        wrote on last edited by
        #3

        @SGaist

        Hi,
        that's what I get :

        
        Device:  USB Audio Analog Stereo
        Device:  Alder Lake PCH-P High Definition Audio Controller Headphones Stereo Microphone
        Device:  Alder Lake PCH-P High Definition Audio Controller Digital Microphone
        defaultDevice:  USB Audio Analog Stereo Id   b'alsa_input.usb-Generic_USB_Audio-00.analog-stereo'
        <PyQt6.QtMultimedia.QAudioDevice object at 0x7fda87807ed0>
        

        from:

        devices = QMediaDevices.audioInputs()
                for device in devices:
                    print("Device: ", device.description())
                defaultdevice = QMediaDevices.defaultAudioInput()
                print("defaultDevice: ", defaultdevice.description(), "Id  ", defaultdevice.id())
                print(QMediaDevices.defaultAudioInput())
        
        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