encoding-guide

First-Time Setup

Setting up your environment correctly is crucial for efficient and high-quality video encoding. This guide ensures that you start with a clean slate and have all necessary tools configured.


Getting a Clean Slate

If you’re on Linux, you can likely skip this step, as the system setup is typically clean. However, for Windows users, it is essential to remove old or conflicting installations of VapourSynth and Python before proceeding.

Steps to Clean Up Old Installations

  1. Uninstall Python:
    • On Windows:
      • Go to Control Panel > Programs > Programs and Features, locate Python, and uninstall all versions.
    • On Linux/macOS:
      sudo apt-get remove python3
      
  2. Uninstall VapourSynth:
    • On Windows:
      • Navigate to Control Panel > Programs > Programs and Features, locate VapourSynth, and uninstall it.
      • Delete any VapourSynth-related entries in the system’s PATH variable.
    • On Linux/macOS:
      sudo apt-get remove vapoursynth
      
  3. Remove Leftover Directories:
    • Check and delete the following directories (on Windows):
      • %APPDATA%/VapourSynth
      • %APPDATA%/Python
      • %LOCALAPPDATA%/Programs/VapourSynth
      • %LOCALAPPDATA%/Programs/Python
  4. Clean Environment Variables:
    • Open System Properties > Environment Variables.
    • Remove any entries related to old Python or VapourSynth installations from the PATH variable.
  5. Reboot Your System:
    • After cleanup, restart your computer to ensure all changes take effect.

Tools You’ll Need

Here’s a list of essential tools for video encoding:

  1. Python (v3.12 or higher): Required for running VapourSynth scripts.
  2. VapourSynth: A frame server for filtering and processing video files.
  3. Encoders:
    • x264: For H.264 encoding.
    • x265: For H.265 encoding.
  4. FFmpeg: For demuxing, remuxing, and audio processing.
  5. MKVToolNix: To merge audio, video, and subtitles.
  6. Other Utilities:

Installing the Tools

Step 1: Install Python

  1. Download: Obtain Python 3.12+ from python.org.
  2. Install: During installation, select the option to add Python to the PATH variable.
  3. Verify Installation:
    python --version
    pip --version
    
  4. Upgrade pip:
    python -m pip install --upgrade pip
    

Step 2: Install VapourSynth

  1. Download: Get VapourSynth from its GitHub page.
  2. Install:
    • On Windows: Run the installer and select all required components.
    • On Linux/macOS
      • Add the deb-multimedia Repository (Required for VapourSynth):
      • Visit deb-multimedia.org for instructions specific to your distribution.

    Example for Debian-based Systems:

    sudo apt update
    sudo apt install -y wget
    wget https://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016.8.1_all.deb
    sudo dpkg -i deb-multimedia-keyring_2016.8.1_all.deb
    sudo apt update
    
  3. Install VapourSynth: After setting up the repository, you can install VapourSynth using the following command:
      sudo apt-get install vapoursynth
    
  4. Verify Installation:
    vspipe --version
    

Step 3: Install Encoders

x264

  1. Download: Get the latest build from VideoLAN.
  2. Install: Place the binary in a folder added to your system’s PATH.

x265

  1. Download: Obtain the encoder from x265’s repository.
  2. Install: Extract the binary and update your PATH.

Step 4: Install FFmpeg

  1. Download: Visit FFmpeg’s website.
  2. Install: Add the bin folder to your PATH.

Step 5: Install MKVToolNix

  1. Download: Get the installer from MKVToolNix’s website.
  2. Verify Installation:
    mkvmerge --version
    

Verifying Your Setup

  1. Create a VapourSynth Script:
    import vapoursynth as vs
    core = vs.get_core()
    clip = core.ffms2.Source("example.mkv")
    clip.set_output()
    
  2. Run the Script:
    vspipe --y4m script.vpy - | ffplay -
    
  3. Check Output: If the video plays, your setup is complete!

With a clean slate and the tools installed, you’re ready to explore advanced filtering and encoding techniques.