Overview
The presets service handles:- Loading built-in and custom presets
- Saving custom presets to persistent storage
- Creating new presets from conversion configs
- Cloning preset configurations
- Managing preset defaults
Import
Type Definitions
PresetDefinition
id- Unique identifier (UUID for custom presets)name- Display name for the presetconfig- Complete conversion configurationbuiltIn- Optional flag indicating built-in preset (cannot be deleted)
Constants
DEFAULT_PRESETS
Array of built-in presets provided by Frame. These presets are read-only and optimized for common use cases.-
Balanced MP4 - General purpose H.264 MP4 with AAC audio
- Container: MP4
- Video: H.264, CRF 23, medium preset
- Audio: AAC 128 kbps
-
Archive H.265 - High-quality archival with H.265
- Container: MKV
- Video: H.265, CRF 18, slow preset
- Audio: AC3 192 kbps
-
Web Share - Optimized for web delivery
- Container: WebM
- Video: VP9, CRF 30, 720p
- Audio: Opus 96 kbps
-
GIF Web Small - Small animated GIFs for web
- Container: GIF
- Resolution: 640x360, 12 fps
- Colors: 128, sierra2_4a dither
-
GIF High Quality - Higher quality animated GIFs
- Container: GIF
- Resolution: 720p, 15 fps
- Colors: 256, floyd_steinberg dither
-
Audio MP3 - Extract audio as MP3
- Container: MP3
- Audio: MP3 128 kbps stereo
-
Audio FLAC (Lossless) - Lossless audio extraction
- Container: FLAC
- Audio: FLAC lossless
-
Audio ALAC (Apple) - Apple lossless audio
- Container: M4A
- Audio: ALAC lossless
-
Audio WAV (Lossless) - Uncompressed PCM audio
- Container: WAV
- Audio: PCM 16-bit
-
Social (TikTok/Reels) - Vertical video for social media
- Container: MP4
- Resolution: 1080x1920, 30 fps
- Video: H.264 6000 kbps bitrate mode
- Audio: AAC 128 kbps, normalized
-
YouTube 1080p - Optimized for YouTube uploads
- Container: MP4
- Resolution: 1080p
- Video: H.264 10000 kbps bitrate mode
- Audio: AAC 320 kbps, normalized
-
YouTube 4K - 4K video for YouTube
- Container: MP4
- Resolution: 3840x2160
- Video: H.264 40000 kbps bitrate mode
- Audio: AAC 320 kbps, normalized
-
X (Landscape) - Optimized for Twitter/X landscape videos
- Container: MP4
- Resolution: 720p, 30 fps
- Video: H.264 2500 kbps bitrate mode
- Audio: AAC 128 kbps, normalized
-
X (Mobile/Portrait) - Portrait videos for Twitter/X
- Container: MP4
- Resolution: 720x1280, 30 fps
- Video: H.264 2000 kbps bitrate mode
- Audio: AAC 128 kbps, normalized
-
Discord - Optimized for Discord uploads
- Container: MP4
- Resolution: 720p, 30 fps
- Video: H.264 1000 kbps bitrate mode
- Audio: AAC 64 kbps, normalized
Functions
loadCustomPresets
Loads user-created custom presets from persistent storage.saveCustomPresets
Saves custom presets to persistent storage.presets- Array of custom presets to save
createCustomPreset
Creates a new custom preset from a conversion configuration.name- Display name for the preset (will be trimmed)config- Conversion configuration to save
cloneConfig
Creates a deep copy of a conversion configuration.config- Configuration to clone
getDefaultConfig
Returns the default conversion configuration (from the first built-in preset).Storage
Custom presets are stored using Tauri’s plugin-store:- File:
presets.dat - Key:
presets - Format: JSON array of PresetDefinition objects
Real-World Usage
Here’s how the presets service is used in Frame’s codebase:Best Practices
Always Clone Configs
When applying a preset, always clone the config to avoid modifying the original:Normalize After Cloning
Always normalize configs after cloning to ensure compatibility:Validate Before Saving
Validate preset names before saving:Handle Storage Errors
Always handle potential storage errors:Related
- Config Service - Configuration normalization
- Conversion Service - Using presets in conversions