Overview
Theconverter package provides the main conversion orchestrator for the Camera Workflow application. It handles parallel processing of images and videos, tracks conversion statistics, manages worker pools, and provides comprehensive progress reporting.
Types
Converter
The main converter type that orchestrates the entire conversion process.Configuration settings for the conversion process
Logger instance for output and file logging
Security checker for file validation and disk space verification
Tracks conversion statistics (processed files, sizes, timings)
ConversionStats
Tracks detailed statistics about the conversion process.Functions
NewConverter
Creates a new Converter instance with the given configuration and logger.Configuration for the conversion process
Logger instance for output
A new Converter instance ready to process files
Example
Methods
Convert
Executes the main conversion process. Automatically switches between copy mode and conversion mode based on configuration.Returns an error if the conversion process fails
Example
Process Flow
- Recovery Phase: Cleanup abandoned files and recover incomplete conversions
- Disk Space Check: Verify sufficient space (unless skipped)
- Safety Test: Test conversion on a sample file
- File Discovery: Walk source directory and categorize files
- Parallel Conversion: Process files with worker pools
- Final Report: Display statistics and cost estimations
findFiles (internal)
Scans the source directory to find all convertible media files.List of photo file paths found
List of video file paths found
Returns an error if directory traversal fails
convertFiles (internal)
Processes a batch of files using parallel worker pools.List of file paths to convert
Type of files (“photo” or “video”)
Worker Pool Behavior
- Photos: Uses configured
MaxJobsworkers - Videos: Limited to 2 workers (or adaptive workers if enabled)
- Adaptive Workers: Dynamically adjusts worker count based on CPU/memory usage
Key Features
Safety Guarantees
- Triple verification before deleting originals
- Processing markers track active conversions with PID/timestamp
- Automatic recovery from crashed processes
- Corruption detection validates existing files
Progress Tracking
- Real-time progress bars with ETA calculations
- Comprehensive statistics (files, sizes, savings)
- S3 storage cost estimations
- JSON mode for programmatic integration
Adaptive Worker Management
When enabled, the converter dynamically adjusts worker count based on:- CPU usage (scales down when CPU > 80%)
- Memory availability (scales down when available memory < 20%)
- Configurable min/max worker limits