This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ffmpeg-normalize is a Python utility for audio normalization using ffmpeg. It supports EBU R128 loudness normalization, RMS-based normalization, and peak normalization for audio and video files.
uv run pytest- Run all testsuv run python -m ffmpeg_normalize [args]- Run the tool directly for testing
uv run ruff check .- Lintinguv run ruff format .- Code formattinguv run ty check- Type checking
uv sync --dev- Install all dependencies (runtime and development)
pdoc -d google -o docs-api ./ffmpeg_normalize- Generate API documentationuvx --with mkdocs-material mkdocs gh-deploy- Deploy MKdocs documentation
To regenerate shell completions after adding new CLI options:
# Bash
uv run python -c "
from ffmpeg_normalize.__main__ import create_parser
import shtab
parser = create_parser()
print(shtab.complete(parser, shell='bash'))
" > completions/ffmpeg-normalize-shtab.bash
# Zsh
uv run python -c "
from ffmpeg_normalize.__main__ import create_parser
import shtab
parser = create_parser()
print(shtab.complete(parser, shell='zsh'))
" > completions/ffmpeg-normalize-shtab.zsh- FFmpegNormalize (
_ffmpeg_normalize.py): Main class that orchestrates the normalization process - MediaFile (
_media_file.py): Represents a media file with its streams and metadata - Stream classes (
_streams.py): AudioStream, VideoStream, SubtitleStream, MediaStream for handling different stream types - Command utilities (
_cmd_utils.py): FFmpeg command generation and execution helpers - Error handling (
_errors.py): Custom exception classes - Logger (
_logger.py): Logging configuration and utilities
The tool supports three normalization types defined in NORMALIZATION_TYPES:
ebu: EBU R128 loudness normalization (default)rms: RMS-based normalizationpeak: Peak normalization
- Console script entry point:
ffmpeg-normalize = ffmpeg_normalize.__main__:main - Module execution:
python -m ffmpeg_normalize
When committing, YOU MUST use conventional commits.
When updating the "What's New" section or the "Features" list, YOU MUST keep both files in sync:
- README.md (root of repository) - The "🆕 What's New" and "✨ Features" sections
- docs/index.md (documentation homepage) - The "🆕 What's New" and "✨ Features" sections
These sections should always contain identical content. When adding a new feature or version announcement:
- Update both files simultaneously
- Ensure formatting and wording are consistent
- Verify links work in both contexts (GitHub links in README, relative links in docs)
When adding, removing, or modifying CLI options, YOU MUST:
- Update the documentation at
docs/usage/cli-options.mdwith the new option details - Regenerate shell completions for bash and zsh (see Shell Completions section above)
- Test the changes with
uv run python -m ffmpeg_normalize --helpto verify help text - Update tests if the new option affects behavior
This ensures users have accurate documentation and working shell completions for all CLI flags.
Important: When modifying CLI descriptions (help texts), make sure to update the corresponding documentation in docs/usage/cli-options.md to keep them consistent, as well as the shell completions.
The project uses:
tqdmfor progress barsffmpeg-progress-yieldfor FFmpeg progress monitoringcolorlogfor colored loggingmutagenfor metadata handlingcolorama(Windows only) for colored terminal output
src/ffmpeg_normalize/- Main package directorytests/- Test files and test media samplesdocs/- MKdocs documentation sourcecompletions/- Shell completion scripts
Tests use pytest and include actual media files in the tests/ directory. The test suite calls the CLI directly using python -m ffmpeg_normalize to test the full pipeline.
- Python 3.9+
- FFmpeg binary must be available in PATH
- The tool checks for FFmpeg loudnorm filter availability at runtime