CaptureSession QML Type | Qt Multimedia | Qt 6.12.0
Description: Allows capturing of audio and video content.
Keywords: qmltype

- Qt 6.12
- Qt Multimedia
- QML Types
- CaptureSession
- Qt 6.12.0 Reference Documentation

# CaptureSession QML Type

Allows capturing of audio and video content. More...

Import Statement: | `import QtMultimedia`
In C++: | QMediaCaptureSession

- List of all members, including inherited members

## Properties

- audioInput : AudioInput
- audioOutput : AudioOutput
- camera : Camera
- imageCapture : ImageCapture
- nativeVideoSource : GStreamerVideoSource `(since 6.12)`
- recorder : MediaRecorder
- screenCapture : ScreenCapture `(since 6.5)`
- videoOutput : VideoOutput
- windowCapture : WindowCapture `(since 6.6)`

## Signals

- audioInputChanged()
- audioOutputChanged()
- cameraChanged()
- imageCaptureChanged()
- nativeVideoSourceChanged()
- recorderChanged()
- videoOutputChanged()

## Detailed Description

This is the central type that manages capturing of media on the local device.

Connect a camera and a microphone to a CaptureSession by assigning Camera and AudioInput objects to the relevant properties.

Capture a screen by connecting a ScreenCapture object to the screenCapture property.

Capture a window by connecting a WindowCapture object to the windowCapture property.

Enable a preview of the captured media by assigning a VideoOutput element to the videoOutput property.

Route audio to an output device by assigning an AudioOutput object to the audioOutput property.

Capture still images from a camera by assigning an ImageCapture to the imageCapture property.

Record audio/video by assigning a MediaRecorder to the recorder property.

     CaptureSession {
         id: captureSession
         camera: Camera {
             id: camera
         }
         imageCapture: ImageCapture {
             id: imageCapture
         }

         recorder: MediaRecorder {
             id: recorder
         }
         videoOutput: preview

         Component.onCompleted: {
             camera.start()
         }
     }

Note: To ensure the camera starts capturing video frames on all platforms, explicitly call camera.start(), typically in the Component.onCompleted handler.

See also Camera, MediaDevices, MediaRecorder, ImageCapture, ScreenCapture, WindowCapture, GStreamerVideoSource, AudioInput, and VideoOutput.

## Property Documentation

### audioInput : AudioInput

This property holds the audio input that is being used to capture audio.

### audioOutput : AudioOutput

The audio output device for the capture session.

Add an AudioOutput device to the capture session to enable audio routing from an AudioInput device.

### camera : Camera

The camera used to capture video.

Record video or take images by adding a camera to the capture session using this property.

### imageCapture : ImageCapture

The object used to capture still images.

Add an ImageCapture interface to the capture session to enable capturing of still images from the camera.

### nativeVideoSource : GStreamerVideoSource `[since 6.12]`

The native video source used to capture video.

For now, it is only possible to set GStreamerVideoSource as the native video source. A capture session can have either Camera or GStreamerVideoSource set at a time.

This property was introduced in Qt 6.12.

See also GStreamerVideoSource and Camera.

### recorder : MediaRecorder

The recorder object used to capture audio/video.

Add a MediaRcorder object to the capture session to enable recording of audio and/or video from the capture session.

### screenCapture : ScreenCapture `[since 6.5]`

The object used to capture a screen.

Record a screen by adding a screen capture objet to the capture session using this property.

This property was introduced in Qt 6.5.

### videoOutput : VideoOutput

The VideoOutput that is the video preview for the capture session.

A VideoOutput based preview is expected to have an invokable videoSink() method that returns a QVideoSink.

The previously set preview is detached.

### windowCapture : WindowCapture `[since 6.6]`

The object used to capture a window.

Record a window by adding a window capture object to the capture session using this property.

This property was introduced in Qt 6.6.

## Signal Documentation

### audioInputChanged()

This signal is emitted when an audio input has changed.

Note: The corresponding handler is `onAudioInputChanged`.

See also CaptureSession::audioInput.

### audioOutputChanged()

This signal is emitted when the selected audio output has changed.

Note: The corresponding handler is `onAudioOutputChanged`.

See also CaptureSession::audioOutput.

### cameraChanged()

This signal is emitted when the selected camera has changed.

Note: The corresponding handler is `onCameraChanged`.

See also CaptureSession::camera.

### imageCaptureChanged()

This signal is emitted when the selected interface has changed.

Note: The corresponding handler is `onImageCaptureChanged`.

See also CaptureSession::camera.

### nativeVideoSourceChanged()

This signal is emitted when the selected native video source has changed.

Note: The corresponding handler is `onNativeVideoSourceChanged`.

See also CaptureSession::nativeVideoSource.

### recorderChanged()

This signal is emitted when the selected recorder has changed.

Note: The corresponding handler is `onRecorderChanged`.

See also CaptureSession::recorder.

### videoOutputChanged()

This signal is emitted when the selected video output has changed.

Note: The corresponding handler is `onVideoOutputChanged`.

See also CaptureSession::videoOutput.