Single script: hevc_converter.py
Modes: CLI + GUI (--gui)
Constraint: hardware encoding only (no CPU encoder fallback).
- Windows PC with AMD RX 7800 XT ->
hevc_amf - MacBook Air M4 ->
hevc_videotoolbox - Homelab with NVIDIA GTX 1070 ->
hevc_nvenc
- Converts
h264sources (unless--force-non-h264is set) - Always outputs MP4 with
-tag:v hvc1 - Copies audio tracks with
-c:a copy - Copies subtitle tracks by default with
--subs copy - Uses default target video bitrate ratio
0.50(--target-ratio 0.50) - Adapts tuning by resolution (360p to 2160p+)
- In
--platform auto, tries hardware encoders in fallback order - Skips conversion when computed target bitrate is greater than or equal to source bitrate
Single file:
python hevc_converter.py -i "D:\video\movie.mkv" -o "D:\video_hevc" --platform amd --quality quality_plus --target-ratio 0.50Recursive folder:
python hevc_converter.py -i "D:\library" -o "D:\library_hevc" --recursive --platform auto --quality quality_plus --target-ratio 0.50GUI:
python hevc_converter.py --guiDry-run (print commands only):
python hevc_converter.py -i "D:\video\movie.mp4" --dry-run --platform nvidiaPrint ffmpeg command before each encode:
python hevc_converter.py -i "D:\video\movie.mp4" --platform amd --print-cmdEncode and score quality vs original:
python hevc_converter.py -i "D:\video\movie.mp4" --platform amd --quality quality_plus --score all --score-sample-seconds 120In single-file mode, after conversion finishes, the GUI enables Open Side-by-Side.
It launches:
video-compare -w 1920x1080 "<input_path>" "<output_path>"video-compare must be available in your PATH.
Available profiles:
archivequality_plusqualitybalancedcompact
Use --score to compare encoded output against the source after each conversion.
--score none: disable scoring (default)--score ssim--score psnr--score vmaf(requires ffmpeglibvmaffilter)--score all(tries VMAF + SSIM + PSNR)
Use --score-sample-seconds N to score only the first N seconds (0 = full video).
The tool prints:
overallscore in0..100- individual metrics (
vmaf,ssim,psnr)
Scoring fallback behavior:
- If
libvmafis missing, VMAF is skipped and the tool still reports SSIM/PSNR when requested.
To compare AMD vs NVIDIA vs Apple quality at the same target ratio:
- Use the same source clip on each machine.
- Run the same profile and ratio (for example
quality_plus,0.50). - Use the same scoring settings (for example
--score all --score-sample-seconds 120). - Compare
overall,vmaf,ssim, andpsnrfrom logs.
Recommended baseline command:
python hevc_converter.py -i "D:\video\sample.mp4" --platform auto --quality quality_plus --target-ratio 0.50 --score all --score-sample-seconds 120 --print-cmd- Preset mapping:
archive,quality_plus:p7quality:p6balanced:p5compact:p4
-tune hq, VBR + CQ, AQ enabled, lookahead by profile- GOP around 2 seconds (
-g fps*2),-bf 4
archive:-usage high_quality-quality quality-rc hqvbr- preanalysis + PA stack enabled
quality_plus:-usage high_quality-quality quality-rc qvbr- preanalysis enabled (lighter than
archive)
quality:-usage high_quality-quality quality-rc qvbr- no heavy preanalysis stack
balanced:-usage transcoding-quality balanced-rc qvbr
compact:-usage transcoding-quality speed-rc qvbr
Practical guidance for 4K:
archive: best quality, slowest (can approach realtime)quality_plus: near-archive quality, fasterquality: strong middle groundbalanced: much fastercompact: fastest and most aggressive compression
- Uses bitrate-targeted hardware HEVC encode path
- Tries to disable software fallback where supported (
-allow_sw 0) - Uses quality-oriented options where available (
-realtime 0, etc.)
- Default:
--subs copy --subs copy: copy subtitle streams (may fail for unsupported subtitle codecs in MP4)--subs mov_text: convert subtitle streams to MP4 text subtitles--subs none: disable subtitle output
- Python 3.10+
ffmpegandffprobeinPATH- ffmpeg build with hardware encoders:
hevc_nvenchevc_amfhevc_videotoolbox
- FFmpeg encoder docs (NVENC/AMF/VideoToolbox):
https://github.com/FFmpeg/FFmpeg/blob/master/doc/encoders.texi - FFmpeg
-tag[:stream_specifier](-tag:v hvc1):
https://ffmpeg.org/ffmpeg-doc.html - NVIDIA FFmpeg usage (Video Codec SDK docs):
https://docs.nvidia.com/video-technologies/video-codec-sdk/10.0/ffmpeg-with-nvidia-gpu/index.html - NVIDIA Encode/Decode support matrix (GTX 1070):
https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new - AMD AMF tuning in FFmpeg:
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/wiki/AMF-Encoder-Settings-and-Tuning-in-FFmpeg - Apple MacBook Air (M4) specs (hardware HEVC encode/decode):
https://www.apple.com/macbook-air/specs/