A high-performance Python-based tool optimized for Apple Silicon Macs, designed to encode and remux Blu-ray discs into more compact and playable formats while maintaining exceptional quality.
- Apple Silicon Optimization: Leverages Apple Silicon's hardware acceleration for maximum performance
- Smart Encoding: Intelligent bitrate calculation based on target file size
- Multi-Stream Support: Handles multiple audio tracks and subtitle streams
- Dolby Vision Support: Preserves Dolby Vision metadata when available
- Hardware Acceleration: Utilizes VideoToolbox for optimal encoding performance
- Quality Preservation: Maintains high quality while achieving significant file size reduction
- Batch Processing: Support for processing multiple files sequentially
- Progress Tracking: Real-time encoding progress and ETA display
- Flexible Output: Customizable output formats and encoding settings
- Error Handling: Robust error handling and logging system
- Configurable Settings: Allows users to customize encoding settings and presets
- Format Detection: Automatic detection and validation of video file formats
- Advanced HDR Support: Comprehensive HDR10, HLG, and Dolby Vision metadata handling
- Intelligent Bitrate Calculation: Dynamic bitrate adjustment based on:
- Content resolution
- Frame rate
- HDR/Dolby Vision presence
- Bit depth
- Codec efficiency
- Input Validation: Thorough validation of input files, system resources, and encoding settings
- Command Line Interface: Support for both CLI arguments and environment variables
- Automatic Output Organization: Creates a "finished" directory for outputs when using CLI
- Enhanced Audio Handling: Support for:
- Dolby Digital Plus
- Dolby Atmos
- Spatial Audio
- Multiple audio stream selection
- Real-time Progress Monitoring: Frame-by-frame progress tracking with stall detection
- Extensive Logging: Detailed logging of:
- System capabilities
- Input analysis
- Encoding parameters
- Progress updates
- Final statistics
- macOS 11.0 (Big Sur) or later
- Apple Silicon processor (M1, M1 Pro, M1 Max, M1 Ultra, M2, or newer)
- Minimum 8GB RAM (16GB recommended for 4K content)
- Sufficient storage space (at least 3x the size of the source file)
- Python 3.8 or later
- FFmpeg 5.0+ with VideoToolbox support
- FFprobe
- pip (Python package installer)
-
Clone the Repository
git clone https://github.com/ZuidVolt/BD-remux-film-encoder.git cd BD-remux-film-encoder
-
Set Up Virtual Environment (Recommended)
python -m venv venv source venv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
-
Install FFmpeg with VideoToolbox Support
brew install ffmpeg
python main.py -i /path/to/input
or if you Prefer not to use command line arguments
Create a .env
file in the project root with the following options:
# Required Settings
INPUT_FILE=/path/to/input
OUTPUT_FILE=/path/to/output
python main.py
You can change the config in the main.py
file by modifying the config
object. The available settings are:
For example, you can modify the config
object in the main.py
file like this:
config = {
"max_ref_frames": "6",
"group_of_pictures": "120",
"audio_bitrate": "768k",
"audio_codec": "eac3",
"audio_channel": "6",
"preset": EncodingPreset.VERYSLOW,
"hdr_params": {
"max_cll": "1600,400",
"master_display": "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,50)",
},
}
Preset | Quality | Speed | File Size |
---|---|---|---|
fast | Low | Fastest | Largest |
medium | Good | Balanced | Balanced |
slow | Better | Slower | Smaller |
target_size_gb
: Target file size in GBpreset
: Encoding preset (fast, medium, slow)maintain_dolby_vision
: Preserve Dolby Vision metadatacopy_audio
: Copy audio streamscopy_subtitles
: Copy subtitle streamsenglish_audio_only
: Only include English audio streamsenglish_subtitles_only
: Only include English subtitle streamsuse_hardware_acceleration
: Use hardware accelerationhardware_encoder
: Hardware encoder to usefallback_encoder
: Fallback encoder to usequality_preset
: Quality preset for encodingallow_sw_fallback
: Allow software fallback for encodingaudio_codec
: Audio codec to useaudio_bitrate
: Audio bitrate to useaudio_channel
: Audio channel layout to usemin_video_bitrate
: Minimum video bitrate to usemax_video_bitrate
: Maximum video bitrate to usehdr_params
: HDR parameters to userealtime
: Real-time encoding modeb_frames
: Number of B-frames to use
Additional Advanced Settings:
dv_profile
: Dolby Vision profile configurationdv_bl_present_flag
: Dolby Vision base layer flagdv_el_present_flag
: Dolby Vision enhancement layer flagdv_bl_signal_compatibility_id
: Dolby Vision compatibility IDprofile_v
: Video profile settingmax_ref_frames
: Maximum reference framesgroup_of_pictures
: GOP size configurationaudio_channel
: Audio channel configuration (up to 7.1 surround)
The tool supports configuration through environment variables:
The encoder automatically detects and utilizes Apple Silicon's hardware acceleration capabilities through VideoToolbox. This provides significant performance improvements:
- Up to 5x faster encoding for 1080p content
- Up to 3x faster encoding for 4K content
- Reduced power consumption
- Lower CPU utilization
- Smart bitrate calculation based on content complexity
- Dynamic frame analysis for optimal quality
- Automatic HDR metadata preservation
- Dolby Vision profile detection and handling
-
Encoding Speed is Slow
- Ensure VideoToolbox is properly configured
- Check system resource usage
- Consider using a faster preset
-
High Memory Usage
- Reduce the number of concurrent tasks
- Increase swap file size
-
Output File Larger Than Expected
- Verify target size settings
- Check audio stream selection
- Consider using a different preset
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Content Type | Source Size | Output Size | Encoding Time | Quality Loss |
---|---|---|---|---|
1080p Movie | 30GB | 5GB | ~58 mins | Negligible |
4K HDR Movie | 60GB | 7GB | ~58 mins | Minimal |
4K DV Movie | 80GB | 11GB | ~58 mins | noticeable |
- Times measured on M3 with 16GB RAM
- FFmpeg team for their incredible tools
- Apple for VideoToolbox framework
- Contributors and testers
For support, please:
- Check the Documentation
- Search existing issues
- Create a new issue if needed
Made with ❤️ for the video encoding community
This project is licensed under the Apache License, Version 2.0 with important additional terms, including specific commercial use conditions. Users are strongly advised to read the full LICENSE file carefully before using, modifying, or distributing this work. The additional terms contain crucial information about liability, data collection, indemnification, and commercial usage requirements that may significantly affect your rights and obligations.
🔍 Keywords: Blu-ray encoding, video compression, FFmpeg, Python automation, macOS optimization, Apple Silicon, M1/M2/M3/M4 optimization, VideoToolbox, hardware acceleration, video transcoding, Dolby Vision, HDR preservation, media processing, remuxing, batch encoding, high-quality compression, video archival, multimedia tools, AV1 encoding, HEVC/H.265, video quality optimization