To use this script:
- Save the script as
hap-encoder.py
- Make sure FFmpeg is installed and available in your system PATH.
- Run from the command line:
- Make sure the script is executable using
chmod -x hap-encoder.py
if using a macOS or Linux system.
python hap-encoder.py input_folder output_folder [--hap-format FORMAT] [--overwrite]
Features:
Processes all MP4 files in the input directory
Creates output directory if it doesn't exist
Preserves original filenames with .mov extension
Supports HAP, HAP Q, and HAP Alpha formats
Skips existing files by default (use --overwrite to force re-encoding)
Provides error reporting for failed conversions
Python 3.6+
FFmpeg with HAP support (most recent versions should work)
The conversion process can be resource-intensive and time-consuming depending on your hardware and video file sizes. For better performance, you might want to add additional FFmpeg parameters like -threads to utilize more CPU cores.