A cross-platform video device control tool compatible with v4l2-ctl, supporting Windows, Linux, and macOS.
- β Cross-Platform Support: Windows, Linux, macOS
- β Device Enumeration: List all available video devices
- β Format Query: Display supported video formats, resolutions, frame rates
- β Parameter Control: View and set device control parameters (brightness, contrast, etc.)
- β v4l2-ctl Compatible: Command-line interface compatible with v4l2-ctl
- β Multiple Backends: DirectShow (Windows), V4L2 (Linux), AVFoundation (macOS), OpenCV (fallback)
# Install from source
git clone https://github.com/yaoian/cross-platform-camera-control.git
cd cross-platform-camera-control
pip install -r requirements.txt
# Or install as package
pip install cross-platform-camera-control# Show help
python v4l2_ctl_cross.py -h
# List all video devices
python v4l2_ctl_cross.py --list-devices
# Show supported formats
python v4l2_ctl_cross.py -d /dev/video0 --list-formats-ext
# Show device controls
python v4l2_ctl_cross.py -d /dev/video0 -L
# Set control parameters
python v4l2_ctl_cross.py -d /dev/video0 -c brightness=50
python v4l2_ctl_cross.py -d /dev/video0 -c brightness=50,contrast=75Device List:
USB Camera: (USB\VID_1BCF&PID_2C9A&MI_00\6&33F8E1A6&0&0000):
/dev/video0
Control Parameters:
User Controls
brightness: 50 (range: 0-100) - Brightness
contrast: 50 (range: 0-100) - Contrast
saturation: 50 (range: 0-100) - Saturation
VideoDeviceController (Abstract Base Class)
βββ WindowsVideoController (Windows Implementation)
β βββ DirectShow API (Primary)
β βββ OpenCV (Fallback)
βββ LinuxVideoController (Linux Implementation)
β βββ V4L2 API
βββ MacOSVideoController (macOS Implementation)
βββ AVFoundation API
pip install pywin32 opencv-pythonpip install v4l2-python opencv-python
# or
sudo apt-get install python3-v4l2pip install pyobjc opencv-python pyobjc-framework-AVFoundationβββ video_device_controller.py # Abstract base class and interfaces
βββ windows_directshow.py # Windows DirectShow implementation
βββ opencv_fallback.py # OpenCV fallback implementation
βββ v4l2_ctl_cross.py # Command-line interface
βββ setup.py # Package configuration
βββ requirements.txt # Dependencies
βββ README.md # Project documentation
- Project architecture design
- Windows platform basic implementation
- OpenCV fallback solution
- Command-line interface
- Device enumeration
- Basic format query
- Basic parameter control
- Complete DirectShow implementation
- Linux V4L2 implementation
- macOS AVFoundation implementation
- Advanced parameter control
- Error handling optimization
- Unit tests
- Performance optimization
| Feature | C++ v4w2-ctl | Python Version |
|---|---|---|
| Platform Support | Windows only | Windows/Linux/macOS |
| Device Enumeration | β | β |
| Format Query | β | β (Basic) |
| Parameter Control | β | β (Basic) |
| DirectShow | β Complete | π In Development |
| V4L2 Support | β | π Planned |
| Installation | Requires compilation | pip install |
# Using MinGW
g++ -o v4w2-ctl.exe v4w2-ctl.cpp ClsDirectShow.cpp -lole32 -loleaut32 -lstrmiids
# Test
./v4w2-ctl.exe -h
./v4w2-ctl.exe --list-devices- Fork the project
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
MIT License - Same as the original project
- Original project author: hry2566
- OpenCV community
- Python community library maintainers
If you encounter any issues or have questions, please open an issue on GitHub.