Configuration API¶
This page documents the configuration models and loader.
Models¶
models ¶
Configuration models for VBC application.
Pydantic models defining the YAML configuration schema with validation rules. All fields have defaults; empty YAML files are valid (use all defaults).
Key models: - AppConfig: Top-level configuration container - GeneralConfig: Core compression settings (threads, GPU, filters, metadata) - GpuConfig: GPU monitoring and sparkline display settings - UiConfig: Dashboard layout and display preferences - AutoRotateConfig: Filename pattern-based rotation rules
Configuration precedence: CLI args > YAML > defaults
GpuEncoderConfig ¶
Bases: BaseModel
NVENC AV1 encoder settings.
CpuEncoderConfig ¶
Bases: BaseModel
CPU encoder settings for SVT-AV1 and advanced AOM modes.
GpuConfig ¶
Bases: BaseModel
GPU monitoring and dashboard sparkline configuration.
Controls GPU metrics sampling and visualization. Metrics include: utilization, memory usage, temperature, and power draw.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled |
bool
|
Enable GPU monitoring and sparkline display. |
refresh_rate |
int
|
[DEPRECATED] Use sample_interval_s instead. |
sample_interval_s |
float
|
Seconds between GPU metric samples (min 0.1s). |
history_window_s |
float
|
Total time window shown in sparklines (min 10s, default 5min). |
nvtop_device_index |
int
|
GPU index to monitor (default 0 for primary GPU). |
nvtop_device_name |
Optional[str]
|
Override device selection by name instead of index. |
nvtop_path |
Optional[str]
|
Custom path to nvtop binary (e.g., /usr/local/bin/nvtop). Auto-detected if not set. |
DynamicRateConfig ¶
Bases: BaseModel
Per-camera bitrate rule for quality_mode='rate'.
DynamicQualityRule ¶
Bases: BaseModel
Per-camera dynamic quality rule.
GeneralConfig ¶
Bases: BaseModel
Core compression and processing configuration.
Controls threading, GPU/CPU selection, file filtering, and metadata handling. Quality targets can be controlled by CQ/CRF (default) or bitrate mode.
Attributes:
| Name | Type | Description |
|---|---|---|
threads |
int
|
Max concurrent compression jobs (default 1, min 1). |
prefetch_factor |
int
|
Submit-on-demand multiplier (jobs = threads * prefetch_factor). |
gpu |
bool
|
Use GPU (NVENC) instead of CPU (SVT-AV1) encoder. |
gpu_refresh_rate |
int
|
[DEPRECATED] Use gpu_config.sample_interval_s. |
queue_sort |
str
|
Queue sorting mode (name, rand, dir, size-asc, size-desc, ext). |
queue_seed |
Optional[int]
|
Random seed for deterministic 'rand' sorting (None = random). |
log_path |
Optional[str]
|
Path to FFmpeg log file (None = use |
cpu_fallback |
bool
|
Retry with CPU if GPU hardware capability exceeded. |
ffmpeg_cpu_threads |
Optional[int]
|
Limit threads per FFmpeg worker (None = FFmpeg decides). |
copy_metadata |
bool
|
Preserve EXIF/XMP metadata from source video. |
use_exif |
bool
|
Extract camera model from EXIF for dynamic_quality matching. |
filter_cameras |
List[str]
|
Only process videos from these camera models (empty = all). |
dynamic_quality |
Dict[str, DynamicQualityRule]
|
Per-camera rules (e.g., {"ILCE-7RM5": {"cq": 38}}). |
quality_mode |
Literal['cq', 'rate']
|
Rate control mode: "cq" (default) or "rate" (bitrate). |
bps |
Optional[str]
|
Target bitrate value for rate mode (absolute or ratio). |
minrate |
Optional[str]
|
Optional minimum bitrate for rate mode (same class as bps). |
maxrate |
Optional[str]
|
Optional maximum bitrate for rate mode (same class as bps). |
rate_target_max_bps |
Optional[str]
|
Optional hard upper cap for resolved target bitrate in rate mode. |
extensions |
List[str]
|
Video file extensions to process. |
min_size_bytes |
int
|
Skip files smaller than this (default 1MiB). |
clean_errors |
bool
|
Remove .err markers and retry failed jobs. |
verify_fail_action |
Literal['false', 'log', 'pause', 'exit']
|
Output verification mode (false, log, pause, exit). |
skip_av1 |
bool
|
Skip files already encoded in AV1 codec. |
strip_unicode_display |
bool
|
Remove unicode chars from displayed filenames (UI safety). |
manual_rotation |
Optional[int]
|
Force rotation angle (0, 90, 180, 270) for all videos (None = auto). |
min_compression_ratio |
float
|
Minimum savings required (0.1 = 10%; keep original if below). |
debug |
bool
|
Enable verbose logging and timing information. |
AutoRotateConfig ¶
Bases: BaseModel
Filename pattern-based automatic rotation configuration.
Maps regex patterns to rotation angles. If a filename matches a pattern, that rotation is applied automatically (overrides manual_rotation).
Attributes:
| Name | Type | Description |
|---|---|---|
patterns |
Dict[str, int]
|
Dict mapping regex patterns to angles (0, 90, 180, 270). Example: {"DJI_..MP4": 0, "GOPR..MP4": 180} |
validate_angles
classmethod
¶
Validate that all rotation angles are 0, 90, 180, or 270 degrees.
Source code in vbc/config/models.py
UiConfig ¶
Bases: BaseModel
Dashboard UI display configuration.
Controls Rich dashboard layout, panel sizing, and display limits.
Attributes:
| Name | Type | Description |
|---|---|---|
activity_feed_max_items |
int
|
Max items in activity feed panel (1-20, default 5). |
active_jobs_max_display |
int
|
Max concurrent jobs to show in panel (1-16, default 8). |
panel_height_scale |
float
|
Dashboard height fraction (0.3-1.0, default 0.7 = 30% reduction). |
WebServerConfig ¶
Bases: BaseModel
Web dashboard server configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled |
bool
|
Start web dashboard automatically (default False). |
port |
int
|
TCP port to listen on (default 8765). |
host |
str
|
Bind address — "0.0.0.0" for all interfaces (LAN access), "127.0.0.1" for localhost only. |
InputDirEntry ¶
Bases: BaseModel
Configured input directory entry with enabled/disabled state.
AppConfig ¶
Bases: BaseModel
Top-level VBC application configuration.
Combines all configuration sections: general, GPU monitoring, encoder, UI, autorotate, and directory mappings.
Directory mapping modes: 1. Suffix mode: input_dirs + suffix_output_dirs (e.g., /videos -> /videos_out) 2. Explicit mode: enabled input_dirs[i] -> output_dirs[i] (1:1 pairing required)
Attributes:
| Name | Type | Description |
|---|---|---|
general |
GeneralConfig
|
Core compression settings. |
input_dirs |
List[InputDirEntry]
|
Ordered list of input directory entries (path + enabled state). |
output_dirs |
List[str]
|
List of output directories for enabled input_dirs (empty = suffix mode). |
suffix_output_dirs |
Optional[str]
|
Suffix for auto-generated output dirs (default "_out"). |
errors_dirs |
List[str]
|
List of .err marker directories for enabled input_dirs (empty = suffix mode). |
suffix_errors_dirs |
Optional[str]
|
Suffix for auto-generated error dirs (default "_err"). |
autorotate |
AutoRotateConfig
|
Filename pattern-based rotation rules. |
gpu_config |
GpuConfig
|
GPU monitoring configuration. |
gpu_encoder |
GpuEncoderConfig
|
GPU encoder configuration. |
cpu_encoder |
CpuEncoderConfig
|
CPU encoder configuration. |
ui |
UiConfig
|
Dashboard UI configuration. |
web_server |
WebServerConfig
|
Read-only HTMX web dashboard configuration. |
DemoInputFolder ¶
Bases: BaseModel
Demo input folder with mockup status and stats.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Folder path/name (e.g., "DEMO/Studio_A"). |
status |
Optional[str]
|
Folder status - "ok", "nonexist", "norw" (None defaults to "ok"). |
files |
Optional[int]
|
Number of files in folder (mockup data for demo display). |
size |
Optional[str]
|
Folder size as string (e.g., "10MB", "1.5GB") for demo display. |
normalize_queue_sort ¶
Normalize and validate queue sorting mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Optional[str]
|
Raw queue_sort value from config or CLI. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Normalized queue_sort mode ("name", "rand", "dir", "size-asc", "size-desc", "ext"). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If value is not a valid queue_sort choice. |
Source code in vbc/config/models.py
validate_queue_sort ¶
Validate queue_sort mode with extension dependency check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Optional[str]
|
Queue sort mode to validate. |
required |
extensions
|
List[str]
|
List of file extensions (required for 'ext' mode). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Validated queue_sort mode. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If 'ext' mode is used without extensions list. |
Source code in vbc/config/models.py
Loader¶
loader ¶
load_config ¶
Loads YAML config and parses it into AppConfig Pydantic model.
Source code in vbc/config/loader.py
save_dirs_config ¶
Update input_dirs field in the YAML config file.
Reads the existing YAML, updates only the input_dirs field, and writes back. All other YAML content is preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Path
|
Path to the vbc.yaml config file. |
required |
input_dirs
|
List[Dict[str, Any]]
|
New ordered list of input directory objects. |
required |
Source code in vbc/config/loader.py
load_demo_config ¶
Loads YAML config and parses it into DemoConfig Pydantic model.
Source code in vbc/config/loader.py
CLI Overrides¶
Helpers that apply CLI option values to loaded YAML configuration.
overrides ¶
build_job_config ¶
build_job_config(base_config: AppConfig, local_registry: Optional[LocalConfigRegistry], file_path: Path, cli_overrides: Optional[CliConfigOverrides]) -> Tuple[AppConfig, ConfigSource]
Build config for a specific job with proper hierarchy.
Applies configuration overrides in priority order: 1. Global config (base_config) 2. Local VBC.YAML (if exists for file's directory) 3. CLI arguments (if provided)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_config
|
AppConfig
|
Global configuration from conf/vbc.yaml. |
required |
local_registry
|
Optional[LocalConfigRegistry]
|
Registry of local VBC.YAML files (optional). |
required |
file_path
|
Path
|
Path to video file being processed. |
required |
cli_overrides
|
Optional[CliConfigOverrides]
|
CLI argument overrides (optional). |
required |
Returns:
| Type | Description |
|---|---|
AppConfig
|
Tuple of (merged_config, config_source_indicator) |
ConfigSource
|
|
Tuple[AppConfig, ConfigSource]
|
|
Source code in vbc/config/overrides.py
Rate Control¶
Validation and normalization helpers for CQ and bitrate-based quality modes.
rate_control ¶
Helpers for bitrate-based quality mode parsing and validation.
Local Registry¶
Helpers for local configuration discovery and persistence.
local_registry ¶
Registry for hierarchical local VBC.YAML configuration files.
Manages discovery and resolution of directory-specific config overrides. Local configs apply to all files in a directory and its subdirectories.
LocalConfigEntry
dataclass
¶
A discovered local VBC.YAML configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path
|
Absolute path to VBC.YAML file. |
directory |
Path
|
Directory containing VBC.YAML. |
data |
Dict[str, Any]
|
Parsed and validated config data (dict). |
depth |
int
|
Directory depth for hierarchy resolution (number of path parts). |
LocalConfigRegistry ¶
Thread-safe registry for local VBC.YAML configurations.
Manages discovery and hierarchical resolution of local config files. Nearest ancestor VBC.YAML wins (child overrides parent).
Initialize empty registry.
Source code in vbc/config/local_registry.py
register ¶
Register a discovered VBC.YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Path
|
Absolute path to VBC.YAML file. |
required |
config_data
|
Dict[str, Any]
|
Parsed and validated config dictionary. |
required |
Source code in vbc/config/local_registry.py
get_applicable_config ¶
Get nearest ancestor VBC.YAML for a file path.
Walks up from file's parent directory to find first matching VBC.YAML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Path
|
Absolute path to video file. |
required |
Returns:
| Type | Description |
|---|---|
Optional[LocalConfigEntry]
|
LocalConfigEntry if found, None otherwise. |
Source code in vbc/config/local_registry.py
build_from_discovery ¶
Scan directory trees and register all VBC.YAML files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dirs
|
List[Path]
|
List of root directories to scan recursively. |
required |
Source code in vbc/config/local_registry.py
Input Directories¶
Validation and mapping helpers for multi-input directory configuration.
Usage Example¶
from pathlib import Path
from vbc.config.loader import load_config
from vbc.infrastructure.ffmpeg import extract_quality_value
# Load from default location
config = load_config(Path("conf/vbc.yaml"))
# Load from custom path
config = load_config(Path("custom.yaml"))
# Access settings
print(f"Threads: {config.general.threads}")
print(f"GPU quality: {extract_quality_value(config.gpu_encoder.common_args)}")
print(f"GPU: {config.general.gpu}")
# Validation happens when creating/parsing models
from vbc.config.models import GeneralConfig
from pydantic import ValidationError
try:
GeneralConfig(threads=0)
except ValidationError as e:
print(e)
Configuration Validation¶
Pydantic models provide automatic validation:
from vbc.config.models import GeneralConfig
from pydantic import ValidationError
# Valid config
config = GeneralConfig(threads=8)
# Invalid: threads must be > 0
try:
config = GeneralConfig(threads=0)
except ValidationError as e:
print(e)
# Field required to be greater than 0
# Invalid: min_compression_ratio must be 0.0-1.0
try:
config = GeneralConfig(min_compression_ratio=1.5)
except ValidationError as e:
print(e)
# Field required to be less than or equal to 1.0
Auto-Rotation Validation¶
from vbc.config.models import AutoRotateConfig
from pydantic import ValidationError
# Valid patterns
config = AutoRotateConfig(patterns={
"DJI_.*\\.MP4": 180,
"GOPR.*": 90
})
# Invalid: angle must be 0, 90, 180, or 270
try:
config = AutoRotateConfig(patterns={
"pattern": 45 # Invalid angle
})
except ValidationError as e:
print(e)
# Invalid rotation angle 45. Must be 0, 90, 180, or 270.