Skip to content

raduslavila/Sinapsa.Video.ConvertorWrap.Net

Repository files navigation

Sinapsa.Video.ConvertorWrap.Net

Sinapsa.Video.ConvertorWrap.Net is a .NET 8 background worker that batch-converts video files with HandBrakeCLI and tracks completed conversions in SQLite.

Features

  • Scans an input folder recursively for supported video files
  • Converts files with HandBrakeCLI
  • Supports CPU and NVIDIA GPU encoding modes
  • Supports 10-bit output selection
  • Preserves relative folder structure in the output folder
  • Avoids reprocessing files by logging completed work in SQLite
  • Can reset logged conversions in development mode
  • Includes a Dockerfile for containerized builds

Tech Stack

  • .NET 8
  • C# 12
  • Generic Host / BackgroundService
  • Microsoft.Extensions.Configuration
  • Microsoft.Extensions.DependencyInjection
  • Microsoft.Data.Sqlite
  • HandBrakeCLI

How it works

At startup, the application:

  1. Loads configuration from appsettings.json and appsettings.Development.json
  2. Registers the hosted worker and supporting services
  3. Scans the configured input directory for supported video files
  4. Builds HandBrakeCLI arguments for each file
  5. Writes converted files to the configured output directory
  6. Stores conversion history in logs/convert.db

Supported input formats

The current implementation scans for these extensions:

  • .mkv
  • .mp4
  • .avi
  • .mov
  • .wmv
  • .flv
  • .mpg
  • .mpeg
  • .webm
  • .m4v

Configuration

The application currently uses these configuration keys:

Key Description
InputFolder Root folder containing source video files
OutputFolder Root folder where converted files are written
OutputProfile Name of the encoding profile from EncodingProfiles
HandBrakeCLI Path to the HandBrakeCLI executable
UseCPU Enables CPU encoding when true
Use10Bit Enables 10-bit encoding when supported by the selected mode
IsDevelopment Clears the conversion log on startup when true
Recoder String appended to the generated output filename

Encoding profiles

Profiles are defined under EncodingProfiles in appsettings.json. Each profile contains:

  • Preset
  • Quality
  • Height

Example configuration

{
  "Recoder": "COPiUmZ",
  "InputFolder": "D:\\Video\\Input",
  "OutputFolder": "D:\\Video\\Output",
  "OutputProfile": "FCPZ_1080p_MeGusta",
  "HandBrakeCLI": "Tools\\HandBrakeCLI.exe",
  "UseCPU": false,
  "Use10Bit": true,
  "IsDevelopment": false
}

Running locally

Requirements

  • .NET 8 SDK
  • HandBrakeCLI available at the configured path
  • Windows environment if you use the bundled Tools\\HandBrakeCLI.exe

Build

dotnet restore
dotnet build

Run

dotnet run --project .\Sinapsa.Video.ConvertorWrap.Net\Sinapsa.Video.ConvertorWrap.Net.csproj

Output and logging

  • Converted files are written under the configured output directory
  • Conversion history is stored in logs/convert.db
  • Each log entry stores:
    • relative input path
    • output path
    • status
    • duration
    • timestamp

Docker

A Dockerfile is included for building and publishing the worker as a container.

Example build:

docker build -t sinapsa-video-convertorwrap-net .

Notes

  • appsettings.Development.json is currently required at startup
  • The project uses a bundled HandBrakeCLI.exe path by default
  • NVIDIA usage detection is present in the code for GPU-related execution flow

License

This project is licensed under the MIT License.

Author

Radu Slavila

About

.NET 8 background worker that batch-converts video files using HandBrakeCLI. Supports CPU and NVIDIA GPU encoding, 10-bit output, and configurable encoding profiles. SQLite-backed conversion log prevents reprocessing. Preserves relative folder structure in output.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors