Skip to content

a CLI tool for GPU accelerated transcoding of large amount of Video files to reduce the size, while ensure preserving the best video quality.

License

Notifications You must be signed in to change notification settings

los0220/batch-video-transcoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Batch Video Transcoder

Batch Video Transcoder is a CLI tool for GPU-accelerated transcoding of a large number of Video files to reduce the size, while ensuring preservation of video quality. It uses FFmpeg to transcode the Video files and VMAF to analyze the output quality. If the desired quality threshold has not been met, the Video will be transcoded again.

How to run

Example commands (Windows PowerShell):

Transcode a single file and keep the result in the out directory:

python batch-video-transcoder.py -i .\test-file.mp4 -o .\out

Transcode multiple files from the in directory and keep the results in the out directory:

python batch-video-transcoder.py -i .\in\* -t 14 --vmaf-workers 2 -cq 38 -q 95 -o .\out

Get help:

python batch-video-transcoder.py --help

General usage

Help command:

usage: batch-video-transcoder.py [-h] [-i INPUT [INPUT ...]] [-o OUTPUT] [-cq [0 - 50]] [-q [0 - 100]] [-v] [-t THREADS] [--transcode-workers TRANSCODE_WORKERS] [--vmaf-workers VMAF_WORKERS]

options:
  -h, --help            show this help message and exit
  -i INPUT [INPUT ...], --input INPUT [INPUT ...]
                        input file path (default: None)
  -o OUTPUT, --output OUTPUT
                        output directory path (default: ./out)
  -cq [0 - 50], --init-cq [0 - 50]
                        initial constant quality (cq) value to transcode with, decreases by 2 on every step (default: 40)
  -q [0 - 100], --quality-treshold [0 - 100]
                        the quality level, below which the file will be transcoded again with higher cq (default: 95)
  -v, --verbose
  -t THREADS, --threads THREADS
                        number of threads to video transcodecompute on (default: 14)
  --transcode-workers TRANSCODE_WORKERS
                        number of paralel workers to transcode on (default: 1)
  --vmaf-workers VMAF_WORKERS
                        number of paralel workers to compute vmaf on (default: 1)

Installation

You don't need to install, just download or clone the repo. If the requirements below are met, you should be able to run the batch-video-transcoder.py directly.

Requirements

  • Python >= 3.10 (I think, developed and tested on 3.12)
  • Nvidia GPU with hevc_nvenc
  • ffmpeg compiled with vmaf in the PATH environmental variable

Tested on Windows 11, but I don't see a reason why it shouldn't work on Linux

FFmpeg

I used gyan.dev Windows build available through winget, which is recommended on the FFmpeg download page and is compiled with VMAF.

winget install Gyan.FFmpeg

License

GNU General Public License v3.0 or later

See LICENSE to see full text

About

a CLI tool for GPU accelerated transcoding of large amount of Video files to reduce the size, while ensure preserving the best video quality.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages