A comprehensive Qt 6 application demonstrating the Qt Multimedia module capabilities, built following Qt best practices.
This project showcases various Qt Multimedia features including:
- Audio Playback: Using MediaPlayer and SoundEffect QML types
- Device Discovery: Enumerating audio/video input and output devices
- Video Playback: Playing video with VideoOutput component
- Audio Capture: Recording audio with MediaRecorder
- Camera & Photos: Capturing photos and recording video with Camera
- MediaPlayer: Full-featured audio playback with seeking, volume control, and playback rate adjustment
- SoundEffect: Low-latency sound playback optimized for UI sounds and game effects
- URL Playback: Load and play audio from various sources (local files, resources, URLs)
- Audio Input Devices: List all available microphones with device metadata
- Audio Output Devices: List all speakers and headphones
- Video Input Devices: List all cameras with position information
- Device Monitoring: Real-time monitoring of device connection/disconnection events
- Highlights default devices for each category
- VideoOutput Component: Display video content with different fill modes
- Playback Controls: Play, pause, stop, and seek through video
- Volume Control: Adjust audio volume during playback
- Fill Modes: Switch between PreserveAspectFit, PreserveAspectCrop, and Stretch
- Video Metadata: Display video properties (duration, has audio/video, seekable)
- Sample video URLs provided for testing
- MediaRecorder: Record audio from selected input device
- Format Selection: Support for WAV, MP3, AAC, and FLAC formats
- Quality Settings: Choose from Very Low to Very High quality
- Audio Level Monitoring: Visual representation of input audio levels
- Playback: Play back recorded audio immediately after recording
- Photo Capture: Take high-quality photos with the camera
- Video Recording: Record video with audio
- Camera Selection: Choose from available cameras
- Quality Settings: Configurable quality for both photos and videos
- Live Preview: Real-time camera viewfinder
- Flash Effect: Visual feedback when capturing photos
- Qt 6.2 or later
- CMake 3.16 or later
- C++17 compatible compiler
- Qt Multimedia module
macOS:
- Camera and microphone permissions may be required
- Grant permissions in System Preferences when prompted
Linux:
- Requires appropriate multimedia backend (GStreamer or PipeWire)
- Install:
sudo apt install libqt6multimedia6-plugins gstreamer1.0-plugins-good
Windows:
- Windows Media Foundation is used by default
- No additional dependencies required
# Create build directory
mkdir build && cd build
# Configure
cmake ..
# Build
cmake --build .
# Run
./QtMultimediaExamples # Linux/macOS
# or
.\QtMultimediaExamples.exe # Windows- Open CMakeLists.txt in Qt Creator
- Configure the project with your Qt 6 kit
- Click "Build" (Ctrl+B / Cmd+B)
- Click "Run" (Ctrl+R / Cmd+R)
- Install the "CMake Tools" extension
- Open the project folder
- Select a kit (Qt 6)
- Press F7 to build
- Press Shift+F5 to run
QtMultimediaExamples/
├── CMakeLists.txt # CMake build configuration
├── README.md # This file
├── src/
│ └── main.cpp # Application entry point
├── qml/
│ ├── Main.qml # Main window with tab navigation
│ ├── AudioPlaybackPage.qml # Audio playback demonstrations
│ ├── DeviceDiscoveryPage.qml # Device enumeration
│ ├── VideoPlaybackPage.qml # Video playback
│ ├── AudioCapturePage.qml # Audio recording
│ └── CameraCapturePage.qml # Camera and photo capture
└── resources/
└── sample_audio.wav # Sample audio file (needs to be generated)
The audio playback examples require a sample audio file. Generate one using:
# Using ffmpeg (cross-platform)
ffmpeg -f lavfi -i "sine=frequency=440:duration=2" -ar 44100 -ac 2 resources/sample_audio.wav
# Or use any .wav file you have
cp /path/to/your/audio.wav resources/sample_audio.wavThis project follows Qt 6 best practices:
- Modern CMake: Uses
qt_add_executableandqt_add_qml_module - QML Module System: Proper QML module with URI and versioning
- Resource Management: Using Qt resource system for embedded files
- Signal Safety: Proper signal/slot connections with lambda functions
- Property Bindings: Declarative QML property bindings where appropriate
- Component Architecture: Modular page-based structure
- Error Handling: Comprehensive error handling for multimedia operations
- Material Design: Uses Qt Quick Controls for native look and feel
- Responsive Layout: Uses Layout components for flexible UI
- High DPI Support: Enabled high DPI scale factor rounding
- MediaPlayer: Audio and video playback
- SoundEffect: Low-latency audio playback
- AudioOutput: Audio output device and volume control
- VideoOutput: Video rendering component
- MediaDevices: Device enumeration and discovery
- CaptureSession: Manages camera and recording pipeline
- Camera: Camera control and configuration
- ImageCapture: Photo capture from camera
- MediaRecorder: Audio and video recording
- AudioInput: Audio input device configuration
- Check device permissions (especially on macOS)
- Ensure devices are properly connected
- On Linux, check that your user is in the
audioandvideogroups
- Grant camera permissions when prompted
- Try selecting a different camera from the dropdown
- Check that no other application is using the camera
- Ensure the sample_audio.wav file exists in resources/
- Check system volume settings
- Verify audio output device is working
- Ensure Qt 6.2+ is installed with Multimedia module
- Check CMake can find Qt:
cmake .. -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x.x/gcc_64 - Verify all QML files are listed in CMakeLists.txt
This is a learning example project. Feel free to use and modify for educational purposes.
This is an educational project. Suggestions and improvements are welcome!
- First run will prompt for camera and microphone permissions
- Recordings are saved to ~/Music and ~/Pictures by default
- Supports both built-in and external cameras
- Requires GStreamer or PipeWire backend
- Default save locations: ~/.local/share/music and ~/.local/share/pictures
- V4L2 cameras are automatically detected
- Uses Windows Media Foundation backend
- Recordings saved to user's Music and Pictures folders
- DirectShow cameras supported
- 1.0.0 - Initial release with all five example pages
Created as a Qt 6 Multimedia learning resource demonstrating best practices.