Overview
The config service handles:- Normalizing conversion configurations based on container and codec compatibility
- Validating configuration options against source metadata
- Ensuring codec and container compatibility
- Handling audio-only and GIF-specific configurations
- Validating hardware encoder settings
- Normalizing GIF-specific options (colors, dither, loop)
Import
Type Definitions
ConversionConfig
Complete conversion configuration structure defined in the Frame source code.MetadataConfig
CropSettings
SourceMetadata
Functions
normalizeConversionConfig
Normalizes a conversion configuration to ensure all options are compatible with the selected container, codecs, and source media.config- The conversion configuration to normalizemetadata- Optional source media metadata for validation
Normalization Rules
The normalization function applies these rules:Audio-Only Sources
If the source has no video codec:- Container is changed to an audio-only format if invalid (defaults to MP3)
- ML upscaling is disabled
- Subtitle tracks are cleared
GIF-Specific
For GIF output:gifColorsis clamped to 2-256gifLoopis clamped to 0-65535gifDitherdefaults to ‘sierra2_4a’ if invalid- Video codec is forced to ‘gif’
- Bitrate mode is forced to ‘crf’
- ML upscaling is disabled
- Hardware acceleration is disabled
Copy Mode
WhenprocessingMode is ‘copy’:
- Subtitle burning is disabled
- Audio normalization is disabled
- Audio volume reset to 100
- Resolution set to ‘original’
- FPS set to ‘original’
- Rotation reset to ‘0’
- Flips disabled
- Crop disabled
- ML upscaling disabled
- Hardware acceleration disabled
Container Compatibility
Audio and subtitle support based on container:Codec Compatibility
Audio and video codecs are validated against the container:Hardware Encoder Settings
NVENC and VideoToolbox settings are validated:ML Upscaling
ML upscaling is incompatible with resolution changes:Video Preset Validation
Video encoder presets are validated:Real-World Usage
Here’s how the config service is used in Frame’s codebase:Best Practices
Always Normalize User Input
Normalize configurations before saving or using them:Provide Metadata When Available
Always pass source metadata for better normalization:Normalize After Preset Application
Always normalize after applying a preset:Re-normalize on Container Change
Re-normalize when the container changes:Validation Helpers
The config service uses these helper modules internally:video-compatibility.ts- Video codec and preset validationmedia.ts- Audio codec validationmedia-rules.ts- Container capability rules
Related
- Presets Service - Managing conversion presets
- Conversion Service - Using configs in conversions