Automated SOFA-based spatial audio processing for video files using FFmpeg.
Auto Sofalizer processes video files by applying SOFA (Spatially Oriented Format for Acoustics) filters to audio tracks, creating immersive spatial audio experiences. The tool automatically:
- Extracts audio tracks from video files
- Applies SOFA spatial audio filters
- Normalizes audio volume (boosts quiet SOFA-processed audio back to optimal levels)
- Muxes the processed audio back into the video
- Sets the processed audio as the default track
- π― Batch Processing: Process entire folders of video files automatically
- π Auto Normalization: Boosts quiet SOFA-processed audio to optimal volume levels
- π¬ Multiple Formats: Supports MKV, MP4, AVI, and other FFmpeg-compatible formats
- π Progress Tracking: Visual progress bars and detailed logging
- π‘οΈ Error Handling: Robust error handling and recovery
- π§ Configurable: Flexible command-line options
- πͺ Cross-Platform: Works on Windows, macOS, and Linux
- π§ͺ Dry Run Mode: Preview operations before processing
- π Detailed Logging: Complete operation logs for debugging
-
Python 3.7+
python --version # Check your Python version -
FFmpeg (with SOFA support)
- Windows: Download from FFmpeg.org or use
winget install FFmpeg - macOS:
brew install ffmpeg - Linux:
sudo apt install ffmpeg(Debian/Ubuntu) orsudo dnf install ffmpeg(Fedora)
- Windows: Download from FFmpeg.org or use
git clone https://github.com/Honey181/auto_sofalizer.git
cd auto_sofalizer
pip install -r requirements.txtpip install -e .This makes auto-sofalizer available as a command anywhere on your system.
python auto_sofalizer.py INPUT_FOLDER OUTPUT_FOLDER EXTENSIONS AUDIO_TRACKArguments:
INPUT_FOLDER: Directory containing video files to processOUTPUT_FOLDER: Directory where processed files will be savedEXTENSIONS: File extensions to process (comma-separated)AUDIO_TRACK: Stream index of audio track to process (usually1for first audio track,2for second, etc.)
python auto_sofalizer.py ./input ./output mkv 1python auto_sofalizer.py ./videos ./processed mkv,mp4,avi 1python auto_sofalizer.py ./input ./output mkv 1 --sofa my_custom.sofapython auto_sofalizer.py ./input ./output mkv 1 --dry-runpython auto_sofalizer.py ./input ./output mkv 1 --keep-temppython auto_sofalizer.py ./input ./output mkv 1 --verbosepython auto_sofalizer.py --helpAvailable options:
--sofa FILE: Specify custom SOFA file (default: irc_1003.sofa)--ffmpeg-verbosity LEVEL: Set FFmpeg logging level--keep-temp: Keep temporary files after processing--dry-run: Show what would be done without processing--verbose,-v: Enable detailed logging--version: Show version information
auto_sofalizer/
βββ auto_sofalizer.py # Main script
βββ irc_1003.sofa # Default SOFA file
βββ requirements.txt # Python dependencies
βββ setup.py # Package installation
βββ README.md # This file
βββ LICENSE # MIT License
βββ CHANGELOG.md # Version history
βββ CONTRIBUTING.md # Contribution guidelines
βββ .gitignore # Git ignore rules
βββ examples/ # Usage examples
βββ example_usage.md
- Extract Audio: Extracts the specified audio track from the video
- Apply SOFA Filter: Processes audio with spatial SOFA filter (typically reduces volume)
- Detect Volume: Analyzes processed audio for peak volume
- Normalize: Boosts audio back to optimal 0dB peak level
- Mux: Combines processed audio back with original video
- Set Default: Marks the processed audio track as default
The default SOFA file (irc_1003.sofa) is included. You can use custom SOFA files:
- Download SOFA files from SOFA Conventions
- Use custom head-related transfer functions (HRTFs)
- Specify with
--sofa your_file.sofa
Error: FFmpeg is not installed or not in PATH
Solution: Install FFmpeg and ensure it's in your system PATH.
Error: SOFA file does not exist
Solution: Ensure irc_1003.sofa is in the script directory or specify path with --sofa.
Error: Audio track X not found
Solution: Use ffprobe to check available audio streams:
ffprobe your_video.mkv 2>&1 | findstr "Stream"Look for the audio streams. Example:
Stream #0:0: Video β Stream 0 (don't use this!)
Stream #0:1: Audio β Stream 1 (first audio - use 1)
Stream #0:2: Audio β Stream 2 (second audio - use 2)
Stream #0:3: Subtitle β Stream 3 (don't use this!)
Important: Count ALL streams (video + audio + subtitles), not just audio tracks!
Solution: Ensure you have write permissions for the output folder.
Processing time depends on:
- Video file size and resolution
- Audio track complexity
- CPU performance
- Storage speed (SSD vs HDD)
Typical rates:
- 1080p video: ~0.5-2x realtime
- 4K video: ~0.2-1x realtime
Contributions are welcome! Please see CONTRIBUTING.md for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- ThreeDeeJay (3DJ) - For the incredible Binaural Audio resources that inspired this project and taught me about HRTF and spatial audio. Join the Discord community for discussions on binaural audio!
- FFmpeg team - For the excellent multimedia framework and SOFA filter support
- SOFA Conventions community - For spatial audio standards
- Contributors and users - For feedback and testing
- π Bug Reports: Open an issue
- π‘ Feature Requests: Open an issue
- Parallel processing support for multiple files
- GUI interface
- Preset SOFA file configurations
- Integration with popular video editors
- Docker container support
- Web interface
See CHANGELOG.md for version history.
Made with β€οΈ for spatial audio enthusiasts