Files
encoding-scripts/README_TV Audio Encoder.md
2025-09-21 21:06:47 +02:00

3.0 KiB

TV Audio Encoder

Overview

tv_audio_encoder.py is a comprehensive batch-processing script for MKV files, specifically designed for encoding TV show episodes. It automates the entire pipeline, including VMAF-targeted video encoding with AV1 (via alabamaEncoder) and sophisticated audio conversion to Opus. To ensure transparency and aid in debugging, the script also preserves detailed, per-file logs of the entire conversion process.

Features

  • Advanced Video Encoding: Uses alabamaEncoder for a simplified yet powerful VMAF-targeted AV1 encoding workflow, aiming for consistent quality.
  • Stable Workflow: Creates a lossless UTVideo intermediate file from the source video, providing a stable and reliable input for the main encoding process.
  • Detailed Logging: Creates a separate, detailed log file for each processed MKV in the conv_logs/ directory, capturing the full terminal output for easy review.
  • Sophisticated Audio Processing: Converts common audio formats to normalized Opus files. It provides an option to downmix surround sound to stereo or preserve the original channel layout.
  • File Organization: Keeps your workspace tidy by automatically moving original files to original/ and completed encodes to completed/.
  • Platform Specificity: The script is designed for Linux systems, as alabamaEncoder is not supported on Windows.

Requirements

The following command-line tools must be installed and available in your system's PATH:

  • ffmpeg
  • ffprobe
  • mkvmerge
  • mkvpropedit
  • sox_ng
  • opusenc
  • mediainfo
  • alabamaEncoder

Usage

  1. Place your .mkv files in the same directory as the script.

  2. Make the script executable by running chmod +x tv_audio_encoder.py.

  3. Execute the script from your terminal:

    ./tv_audio_encoder.py
    

Optional Arguments

  • --no-downmix: By default, the script downmixes surround sound audio (e.g., 5.1, 7.1) to stereo. Use this flag to preserve the original audio channel layout.

    Example:

    ./tv_audio_encoder.py --no-downmix
    
  • --autocrop: Automatically detect and crop black bars from video using cropdetect. The crop is applied only to the UTVideo intermediate file, ensuring no image data is lost even with variable crops.

    Example:

    ./tv_audio_encoder.py --autocrop
    

    You can combine with --no-downmix:

    ./tv_audio_encoder.py --autocrop --no-downmix
    

Output

  • Processed files are moved to the completed/ directory.
  • Original files are moved to the original/ directory.
  • Per-file logs are saved in the conv_logs/ directory.

Notes

  • This script is intended for use on Linux only.
  • The entire process, especially the AV1 encoding, can be very time-consuming and CPU-intensive. Be prepared for long processing times, especially on large files or less powerful machines.
  • Consider testing with a single file first to fine-tune your desired settings before batch processing a large library of videos.