152 lines
3.6 KiB
Markdown
152 lines
3.6 KiB
Markdown
# 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
|
|
|
|
- [Deno](https://deno.com/) v1.0 or higher
|
|
- [FFmpeg](https://ffmpeg.org/) with libsvtav1 support
|
|
- [FFprobe](https://ffmpeg.org/ffprobe.html) (usually bundled with FFmpeg)
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone <repository-url>
|
|
cd videenc_ts
|
|
```
|
|
|
|
2. Ensure you have Deno installed:
|
|
```bash
|
|
deno --version
|
|
```
|
|
|
|
3. Ensure you have FFmpeg with libsvtav1 installed:
|
|
```bash
|
|
ffmpeg -version
|
|
ffmpeg -h encoder=libsvtav1
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Basic Usage
|
|
|
|
```bash
|
|
./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:
|
|
|
|
1. Get an API key from [OMDB API](http://www.omdbapi.com/apikey.aspx)
|
|
2. Add it to your settings file at `~/.config/videnc/settings.json`:
|
|
```json
|
|
{
|
|
"omdb_api_key": "your_api_key_here"
|
|
}
|
|
```
|
|
3. Run the encoder with a video file:
|
|
```bash
|
|
./videnc -i <input_video_file>
|
|
```
|
|
4. 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
|
|
|
|
```bash
|
|
make build
|
|
```
|
|
|
|
### Using Deno Compile
|
|
|
|
```bash
|
|
deno compile --allow-all --output ./videnc ./src/main.ts
|
|
```
|
|
|
|
Both methods will create a standalone executable named `videnc`.
|
|
|
|
## How It Works
|
|
|
|
1. **Video Analysis**: Uses FFprobe to analyze the input video file and extract
|
|
technical information
|
|
2. **Metadata Fetching**: Optionally fetches metadata from OMDB API using the
|
|
provided IMDb ID
|
|
3. **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
|
|
4. **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
|
|
5. **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
|
|
|
|
```bash
|
|
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](LICENSE) file
|
|
for details.
|