kingstefan26 / alabamaEncoder

AlabamaEncoder is a video encoder framework, with a focus on chunked target quality encoding
MIT License
16 stars 1 forks source link
av1 video-processing vmaf

AlabamaEncoder

AlabamaEncoder is a powerful video encoding framework designed for macOS & Linux. It is able to leverage multi-PC setups, and currently supports various encoders such as SVT-AV1, aomenc, rav1e, x265, and x264, among others.

Note: this utility is a work in progress. It may not function as expected. Please report any issues you encounter.

Installation

Recommended way, install with pipx

pipx install alabamaEncoder

But if you are a developer

  1. First, clone the upstream GitHub repository:
git clone https://github.com/kingstefan26/alabamaEncoder
  1. Next, set up the Python virtual environment:
python -m venv venv
source venv/bin/activate

Note: make sure to use venv/bin/activate.fish if you use the fish shell

  1. Finally, install the required dependencies:
pip install -r requirements.txt

From here, you can either run the program without building it, or build & install it.

Run Without Building

python -m alabamaEncode.cli <cli_args>

Build & Install

To build and install the local version:

pip install build
python -m build
pipx install . --editable --force

Ensure SvtAv1EncApp, ffmpeg, ffprobe, and any other encoder binaries you wish to use are available in your PATH. The program will notify you if any dependencies are missing.

Command-Line Interface (CLI)

For local or Celery-based encoding, use:

alabamaEncoder [-h] [INPUT FILE] [OUTPUT FILE] [flags]

For a more comprehensive breakdown of the arguments and flags, see our USAGE page.

Non-Mainline Encoders

To use one of the many community-built forks of mainline video encoders ( like SVT-AV1-PSY), you may do the following:

Example:

export SVTAV1ENCAPP_CLI_PATH=/path/to/SvtAv1EncApp # Custom path
alabamaEncoder [arguments...]

This applies to all binaries used by AlabamaEncoder. So, to use a custom build of ffmpeg, set the FFMPEG_CLI_PATH environment variable.

Multi-System Encoding

Setup

docker run -d -p 6379:6379 --rm redis

Set the Redis host environment variable for both workers and the main command:

export REDIS_HOST=192.168.1.10
alabamaEncoder worker 10

By default, the Redis host is assumed to be localhost.

To clear the Celery job queue:

alabamaEncoder clear

Notes

Examples

Here's an example of an Adaptive encoding command for alabamaEncoder:

alabamaEncoder input.mkv auto --autocrop -res 1080p --grain -2 --hdr --audio_params "-c:a libopus -b:a 170k -ac 6 -mapping_family 1" --vmaf_target 95 --end_offset 60 --start_offset 60 --title "TV SHOW (2023) S00E00"

Now, let's break down what this command is doing:

This example uses the auto output path, it automatically makes up an output dir based on the title, so alabamaEncoder will encode ./input.mkv to ~/showsEncode/TV SHOW (2024)/s0/e0/TV.SHOW.2023.S00E00.AV1.OPUS.Placeholder.webm

Crops black bars

Downscales to a 1080p class resolution

Automatically adjusts film grain synthesis parameters on a per-scene basis

Preserves HDR metadata resulting in a proper HDR output

Transcode audio to 170k 5.1 Opus

Calculate the ideal CRF to achieve a VMAF score of 95 on a per-scene basis

Cuts the first and last minute.

Adds metadata title.

Encodes using SvtAv1EncApp by default when an encoder is not specified.


Here's an example of a Constant Rate Factor encoding command for alabamaEncoder:

alabamaEncoder /path/to/movie.mkv ./dir/out.webm --audio_params "-c:a libopus -b:a 256k -ac 8 -mapping_family 1" --grain 17 -res 1080p --crf_mode --crf 24 --encoder AOMENC

This command:

Notes

Credits

Thanks to all contributors and developers of the tools used in this project.