This repository contains reference code for DeckLink video capture with text overlay. It is maintained for architectural reference and pattern documentation but is no longer actively developed. For production 24/7 recording, use ffrecord.
Real-time video/audio capture from Blackmagic DeckLink cards with optional dynamic text overlay and dual output (GUI display and playout).
Key Patterns:
- DeckLink hardware integration (COM, comtypes, native bindings)
- A/V synchronization and frame alignment
- Real-time text overlay rendering
- PyQt6 GUI for live monitoring
- Cross-platform architecture (Windows/macOS/Linux)
- DeckLink Input Capture: Capture high-quality video/audio from one DeckLink card (when configured)
- Dynamic Text Overlay: Read and overlay text from a local file on each frame
- Real-time Monitoring: Live GUI display of the current frame
- DeckLink Playout: Output processed video/audio to a second DeckLink card (when configured)
- Simulation Mode: Test with video files instead of hardware (no dependencies)
- Portable Setup: Virtual environment ensures all dependencies are isolated
- Cross-Platform: Works on Windows, macOS, and Linux with the same code
- Multiple Backends: Auto-detects and uses the best available capture method
| Feature | Status | Notes |
|---|---|---|
| Application Architecture | ✅ Complete | Fully working pipeline |
| Simulation Mode | ✅ Working | Test with video files - no hardware needed |
| Text Overlay Engine | ✅ Working | Real-time file monitoring implemented |
| GUI Display | ✅ Working | PyQt6 displays frames correctly |
| DeckLink Hardware | See Hardware Setup Guide |
Recommendation: Start with Simulation Mode to verify everything works. See Simulation Mode Quick Start. For hardware setup see DeckLink Setup Guide.
cd C:\dev\ffcapture
.\setup.ps1# Create a simple 10-second test video
ffmpeg -f lavfi -i color=c=blue:s=1920x1080:d=10 `
-f lavfi -i sine=f=1000:d=10 `
C:\temp\test_video.mp4Edit src/config.py:
SIMULATE_HARDWARE = True
SIMULATION_INPUT_FILE = r"C:\temp\test_video.mp4" # already present below"Initial text line" | Out-File -Encoding UTF8 C:\temp\lines.txtpython src\main.pyYou should see the video with text overlay in the GUI window!
See DeckLink Setup Guide for:
- Driver and COM object installation
- Device index configuration
- Step-by-step verification with
verify_decklink.ps1
Perfect for development, testing, and hardware-independent verification.
# In src/config.py:
SIMULATE_HARDWARE = True
SIMULATION_INPUT_FILE = r'C:\temp\test_video.mp4'Benefits:
- ✅ No hardware required
- ✅ Fully portable
- ✅ Instant feedback
- ✅ Perfect for testing overlays and GUI
See Simulation Mode Quick Start for detailed guide.
When you're ready to use real DeckLink hardware:
- First read DeckLink Setup Guide
- Install drivers and register COM objects (requires admin privileges)
- Set
SIMULATE_HARDWARE = Falseinsrc/config.py - Application auto-detects and uses hardware
Hardware and pipeline settings are in src/config.py. Text overlay settings are in src/config_subtitles.py. Key settings:
src/config.py
| Setting | Purpose | Default |
|---|---|---|
CAPTURE_DEVICE_INDEX |
Which DeckLink card to use for input | 0 |
PLAYOUT_DEVICE_INDEX |
Which DeckLink card to use for output | 1 |
SIMULATE_HARDWARE |
Use video file instead of hardware | False |
SIMULATION_INPUT_FILE |
Video file path for simulation mode | C:\temp\test_video.mp4 |
CAPTURE_QUEUE_SIZE |
Frame buffer depth from capture | 16 |
GUI_UPDATE_RATE |
Max GUI refresh rate (Hz) | 25 |
src/config_subtitles.py
| Setting | Purpose | Default |
|---|---|---|
TEXT_FILE |
Path to text file for overlay | C:\temp\lines.txt |
TEXT_FONT_SIZE |
Font size in pixels | 70 |
TEXT_OFFSET_BOTTOM |
Pixels from bottom edge | 98 |
TEXT_ALIGN |
Horizontal alignment (left/center/right) |
center |
TEXT_COLOR |
Text colour (BGR tuple) | (255, 255, 255) |
TEXT_BG_COLOR |
Background colour (BGR tuple) | (0, 0, 0) |
While the application is running, you can update the text:
# PowerShell: append new line to text file
"New overlay text" | Out-File -Append C:\temp\lines.txt
# The overlay updates within 1-2 frames┌─────────────────┐
│ DeckLink Input │
└────────┬────────┘
│
┌────▼─────────┐
│ Frame Capture │
└────┬─────────┘
│
┌────▼────────────────────┐
│ Text Overlay Engine │
│ (reads C:\temp\lines.txt)│
└────┬───────────┬──────────┘
│ │
┌────▼───┐ ┌────▼────────┐
│ GUI │ │ DeckLink │
│Display │ │ Playout Card │
└────────┘ └─────────────┘
- Verify DeckLink drivers installed: Check Windows Device Manager
- Check card is properly seated in PCIe slot
- Try restarting the computer
- Check if PyQt6 installed correctly:
pip list | grep PyQt6 - Try running in headless mode: set
SKIP_GUI = Truein config.py
- Verify text file exists at configured path
- Check file permissions (must be readable)
- Look at logs in
logs/ffcapture.log
- Check CPU usage (should be under 50%)
- Reduce overlay complexity (smaller font, simpler text)
- Increase
CAPTURE_QUEUE_SIZEin config.py
Application logs are saved to logs/ffcapture.log. Check here for detailed error messages.
C:\dev\ffcapture/
├── src/
│ ├── __init__.py # Package definition
│ ├── main.py # Entry point
│ ├── config.py # Hardware/pipeline configuration
│ ├── config_subtitles.py # Text overlay configuration
│ ├── logger.py # Logging setup
│ ├── capture.py # Capture backends (sim + DeckLink COM)
│ ├── capture_pyav_decklink.py # PyAV/FFmpeg DeckLink backend
│ ├── decklink_com.py # DeckLink COM wrapper (pywin32)
│ ├── decklink_comtypes.py # DeckLink comtypes backend
│ ├── decklink_native.py # DeckLink native library backend
│ ├── overlay.py # Text overlay engine
│ ├── outputs.py # Encoding outputs (UDP, TS file)
│ ├── playout.py # DeckLink playout
│ ├── gui.py # GUI display
│ └── pipeline.py # Main orchestration
├── tests/ # Unit tests
├── docs/ # Documentation
├── requirements.txt # Python dependencies
├── setup.ps1 # Setup script
├── verify_decklink.ps1 # Hardware verification script
└── README.md # This file
For architectural notes and implementation details, see docs/IMPLEMENTATION_NOTES.md.
- av (PyAV): FFmpeg bindings
- opencv-python: Image processing
- numpy: Array operations
- PyQt6: GUI framework
All managed via virtual environment in venv/.
[Your License Here]
For issues or questions, check the logs and AGENTS.md documentation.