Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Two webcams and their audio



  • I have two Logitech BRIO webcams and can readily switch between them by selecting their unique deviceId. Here is the QML code for context

    import QtQuick 2.9
    import QtMultimedia 5.12
    
    Rectangle {
            property int camIndex: 0        
            property string dutId: ""
    
    	onDutIdChanged: {
    		var camId = camera.deviceId
    		if(dutId == camId) {
    			console.log("*** match for: " + camId)
    		}
    	}
    	
    	Camera {
    		id: camera
    		captureMode: Camera.CaptureStillImage
    		deviceId: QtMultimedia.availableCameras[camIndex].deviceId
    
    		videoRecorder {
    			resolution: "1280x720"
    			frameRate: 30
    		}
    	}
    }
    

    However, the audio source for each webcam must be found independently. I can enumerate the audio devices using QAudioDeviceInfo, but they identify only as
    Logitech BRIO
    Logitech BRIO

    Question 1: How to know which audio device belongs to each webcam microphone?

    Question 2: How to switch webcam and audio together?

    The QAudioRecorder class has helpful availableInputs() and setActiveInput(), methods, but the QCamera and QMediaRecorder classes do not. I suspect that I need to find a QMediaService from which I can get a QAudioInputSelectorControl. However I have failed to make it work.

    Any suggestions?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What OS are you running on ?



  • MacOS, but I like cross-platform solutions.


  • Lifetime Qt Champion

    Each platform returns different informations hence the need to know on which one you are working.

    Can you check what you have in the Sound part of the System Settings ?


Log in to reply