Batch-compress raw YUV test sequences into H.265 / HEVC MP4 files with ffmpeg-python.
Preview image source: the public FFmpeg homepage at https://www.ffmpeg.org/.
- Scans a directory for
.yuvfiles. - Parses resolution and frame-rate metadata from filenames.
- Encodes with
libx265through FFmpeg. - Writes
.mp4outputs into a separate directory. - Uses a deterministic bitrate heuristic for quick testing.
Input files are expected to follow:
<name>_<width>x<height>_<framerate>.yuv
Example:
BasketballDrive_1920x1080_50.yuv
Install FFmpeg first:
brew install ffmpegInstall Python dependencies:
pip install ffmpeg-pythonInstall this package locally:
pip install -e .from h265_compress.compress import compress_video
compress_video(
source_dir="raw_yuv",
output_dir="encoded_mp4",
)The current encoder settings prioritize a simple PSNR-oriented test path:
vcodec=libx265
preset=placebo
tune=psnr
pix_fmt=yuv420p
This is useful for controlled experiments, not for fastest production encoding.
MIT
