f3f88edc0f287c3415df31461cc02d83b199b9ee
Video Encoder (videnc)
A Deno-based video encoding application that converts videos to the AV1 video codec with Opus audio in MKV containers.
Features
- Encodes videos to AV1 (libsvtav1) for high efficiency
- Converts audio to Opus for excellent quality at low bitrates
- Automatically detects video properties (resolution, frame rate, interlacing, anamorphic content)
- Applies appropriate filters for interlaced and anamorphic content
- Preserves and embeds metadata
- Integrates with OMDB API for automatic metadata fetching
- Generates shell scripts for encoding commands
- Supports multiple audio and subtitle streams
Prerequisites
Installation
-
Clone the repository:
git clone <repository-url> cd videenc_ts -
Ensure you have Deno installed:
deno --version -
Ensure you have FFmpeg with libsvtav1 installed:
ffmpeg -version ffmpeg -h encoder=libsvtav1
Usage
Basic Usage
./videnc -i <input_video_file>
This will analyze the video and generate a shell script (encode.sh or
encode_N.sh) containing the FFmpeg command for encoding.
With OMDB Metadata
To use OMDB metadata:
- Get an API key from OMDB API
- Add it to your settings file at
~/.config/videnc/settings.json:{ "omdb_api_key": "your_api_key_here" } - Run the encoder with a video file:
./videnc -i <input_video_file> - When prompted, enter the IMDb ID for the video (e.g., tt0111161 for The Shawshank Redemption)
Building
You can build the application in two ways:
Using Make
make build
Using Deno Compile
deno compile --allow-all --output ./videnc ./src/main.ts
Both methods will create a standalone executable named videnc.
How It Works
- Video Analysis: Uses FFprobe to analyze the input video file and extract technical information
- Metadata Fetching: Optionally fetches metadata from OMDB API using the provided IMDb ID
- Profile Selection: Automatically selects encoding profiles based on video
resolution:
- DVD profile for videos with less than 1 megapixel
- BluRay profile for higher resolution videos
- Command Generation: Creates an optimized FFmpeg command with appropriate
settings for:
- Video encoding (AV1 with libsvtav1)
- Audio encoding (Opus)
- Subtitle handling (copy)
- Metadata embedding
- Filters for interlaced and anamorphic content
- Script Creation: Generates a shell script with the encoding command
Encoding Profiles
DVD Profile
- CRF: 29
- Preset: 2
- Film Grain: 5
BluRay Profile
- CRF: 27
- Preset: 2
- Film Grain: 5
Example Generated Command
ffmpeg \
-hide_banner \
-i "input_video.mp4" \
-map_metadata -1 \
-map 0:v \
-c:v libsvtav1 \
-pix_fmt yuv420p10le \
-crf 27 \
-svtav1-params keyint=120:tune=0:film-grain=5:scd=1:film-grain-denoise=1:enable-overlays=1:enable-qm=1:qm-min=0:qm-max=15 \
-preset 2 \
-vf "bwdif=mode=0,scale=iw*sar:ih:lanczos,setsar=1,scale=-2:ih:lanczos" \
-map 0:a:0 \
-c:a:0 libopus \
-metadata:s:a:0 language=eng \
-disposition:a:0 default \
-map 0:s:0 \
-c:s:0 copy \
-metadata:s:s:0 language=eng \
-disposition:s:0 -1 \
"output_video.av1.mkv"
License
This project is licensed under the MIT License - see the LICENSE file for details.
Languages
TypeScript
99%
Makefile
1%