def imageSettings(self):
        settings = self.imagecapture.encodingSettings()
        settings.setCodec(self.boxValue(self.ui.imageCodecBox))
        settings.setQuality(
            QMultimedia.EncodingQuality(self.ui.imageQualitySlider.value()))
        settings.setResolution(self.boxValue(self.ui.imageResolutionBox))

        return settings
Esempio n. 2
0
    def audioSettings(self):
        settings = self.mediaRecorder.audioSettings()
        settings.setCodec(self.boxValue(self.ui.audioCodecBox))
        settings.setQuality(
            QMultimedia.EncodingQuality(self.ui.audioQualitySlider.value()))
        settings.setSampleRate(self.boxValue(self.ui.audioSampleRateBox))

        return settings
Esempio n. 3
0
    def videoSettings(self):
        settings = self.mediaRecorder.videoSettings()
        settings.setCodec(self.boxValue(self.ui.videoCodecBox))
        settings.setQuality(
            QMultimedia.EncodingQuality(self.ui.videoQualitySlider.value()))
        settings.setResolution(self.boxValue(self.ui.videoResolutionBox))
        settings.setFrameRate(self.boxValue(self.ui.videoFramerateBox))

        return settings
Esempio n. 4
0
    def __setRecordParams(self):  ##设置音频输入参数
        selectedFile = self.ui.editOutputFile.text().strip()
        if (selectedFile == ""):
            QMessageBox.critical(self, "错误", "请先设置录音输出文件")
            return False

        if os.path.exists(selectedFile):
            os.remove(selectedFile)  #删除已有文件

    ##         QMessageBox.critical(self,"错误","录音输出文件被占用,无法删除")
    ##         return False

        recordFile = QUrl.fromLocalFile(selectedFile)
        self.recorder.setOutputLocation(recordFile)  #设置输出文件

        recordDevice = self.ui.comboDevices.currentText()
        self.recorder.setAudioInput(recordDevice)  #设置录入设备

        settings = QAudioEncoderSettings()  #音频编码设置
        settings.setCodec(self.ui.comboCodec.currentText())  #编码

        sampRate = int(self.ui.comboSampleRate.currentText())
        settings.setSampleRate(sampRate)  #采样率

        bitRate = int(self.ui.comboBitrate.currentText())
        settings.setBitRate(bitRate)  #比特率

        channelCount = int(self.ui.comboChannels.currentText())
        settings.setChannelCount(channelCount)  #通道数

        ##      quality=self.ui.sliderQuality.value()   #也可以
        quality = QMultimedia.EncodingQuality(self.ui.sliderQuality.value())
        settings.setQuality(quality)  #品质

        if self.ui.radioQuality.isChecked():  #编码模式为固定品质,自动决定采样率,采样点大小
            settings.setEncodingMode(QMultimedia.ConstantQualityEncoding)
        else:
            settings.setEncodingMode(
                QMultimedia.ConstantBitRateEncoding)  #固定比特率

        self.recorder.setAudioSettings(settings)  #音频设置
        return True