# k4yt3x/video2x architecture

> Architecture diagram of the GitHub repository k4yt3x/video2x, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/k4yt3x/video2x
- Repository: https://github.com/k4yt3x/video2x

## Overview

Video2X is a C/C++ video upscaling and frame-interpolation framework. The CLI gathers input, output, codec, and processor settings; the library orchestrates decoding, applies a selected filter or interpolator, then encodes the result while optionally preserving audio and subtitles. Documented processing choices include Anime4K/custom GLSL via libplacebo, Real-ESRGAN, Real-CUGAN, and RIFE. The source excerpts establish the main orchestration and processor dispatch; unsampled implementation details are represented only where the README or source index supports them.

Main entry points: [`src/libvideo2x.cpp`](https://github.com/k4yt3x/video2x/blob/master/src/libvideo2x.cpp) (Video processor), [`src/processor_factory.cpp`](https://github.com/k4yt3x/video2x/blob/master/src/processor_factory.cpp) (Processor factory), [`tools/video2x/src/argparse.cpp`](https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/argparse.cpp) (Argument parsing), [`tools/video2x/src/video2x.cpp`](https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/video2x.cpp) (CLI entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command line"]
  node_args["Argument parsing<br/>[argparse.cpp]"]
  node_validators["Option validators<br/>[validators.cpp]"]
  node_cli_main["CLI entry point<br/>[video2x.cpp]"]
end

subgraph group_pipeline["Video pipeline"]
  node_orchestrator["Video processor<br/>[libvideo2x.cpp]"]
end

subgraph group_processors["Processing engines"]
  node_factory["Processor factory"]
  node_libplacebo["libplacebo filter"]
  node_realesrgan["Real-ESRGAN filter"]
  node_realcugan["Real-CUGAN filter"]
  node_rife["RIFE interpolator"]
end

subgraph group_media["Media support"]
  node_decoder["Video decoder<br/>[decoder.cpp]"]
  node_encoder["Video encoder<br/>[encoder.cpp]"]
  node_conversions["Frame conversions<br/>[conversions.cpp]"]
  node_avutils["AV utilities<br/>[avutils.cpp]"]
  node_fsutils["Filesystem utilities<br/>[fsutils.cpp]"]
  node_logger["Logging manager<br/>[logger_manager.cpp]"]
  node_vulkan["Vulkan device support<br/>[vulkan_utils.cpp]"]
end

node_user(("Video user"))

node_user -->|"sets options"| node_args
node_args -->|"validates values"| node_validators
node_args -->|"provides arguments"| node_cli_main
node_cli_main -.->|"starts processing"| node_orchestrator
node_orchestrator -->|"initializes decoder"| node_decoder
node_orchestrator -->|"creates processor"| node_factory
node_factory -->|"creates filter"| node_libplacebo
node_factory -->|"creates filter"| node_realesrgan
node_factory -->|"creates filter"| node_realcugan
node_factory -->|"creates interpolator"| node_rife
node_orchestrator -->|"initializes encoder"| node_encoder
node_orchestrator -->|"filters frames"| node_libplacebo
node_orchestrator -->|"filters frames"| node_realesrgan
node_orchestrator -->|"filters frames"| node_realcugan
node_orchestrator -->|"interpolates frames"| node_rife
node_orchestrator -->|"writes frames"| node_encoder
node_libplacebo -->|"resolves resources"| node_fsutils
node_realesrgan -->|"converts frames"| node_conversions
node_realcugan -->|"converts frames"| node_conversions
node_rife -->|"converts frames"| node_conversions
node_cli_main -.->|"selects device"| node_vulkan

click node_args "https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/argparse.cpp"
click node_validators "https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/validators.cpp"
click node_cli_main "https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/video2x.cpp"
click node_orchestrator "https://github.com/k4yt3x/video2x/blob/master/src/libvideo2x.cpp"
click node_decoder "https://github.com/k4yt3x/video2x/blob/master/src/decoder.cpp"
click node_factory "https://github.com/k4yt3x/video2x/blob/master/src/processor_factory.cpp"
click node_libplacebo "https://github.com/k4yt3x/video2x/blob/master/src/filter_libplacebo.cpp"
click node_realesrgan "https://github.com/k4yt3x/video2x/blob/master/src/filter_realesrgan.cpp"
click node_realcugan "https://github.com/k4yt3x/video2x/blob/master/src/filter_realcugan.cpp"
click node_rife "https://github.com/k4yt3x/video2x/blob/master/src/interpolator_rife.cpp"
click node_encoder "https://github.com/k4yt3x/video2x/blob/master/src/encoder.cpp"
click node_conversions "https://github.com/k4yt3x/video2x/blob/master/src/conversions.cpp"
click node_avutils "https://github.com/k4yt3x/video2x/blob/master/src/avutils.cpp"
click node_fsutils "https://github.com/k4yt3x/video2x/blob/master/src/fsutils.cpp"
click node_logger "https://github.com/k4yt3x/video2x/blob/master/src/logger_manager.cpp"
click node_vulkan "https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/vulkan_utils.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_args,node_validators,node_cli_main,node_user toneBlue
class node_orchestrator toneAmber
class node_factory,node_libplacebo,node_realesrgan,node_realcugan,node_rife toneMint
class node_decoder,node_encoder,node_conversions,node_avutils,node_fsutils,node_logger,node_vulkan toneRose
```

## Components

### Command line

- [Argument parsing](https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/argparse.cpp): `tools/video2x/src/argparse.cpp`
- [Option validators](https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/validators.cpp): `tools/video2x/src/validators.cpp`
- [CLI entry point](https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/video2x.cpp): `tools/video2x/src/video2x.cpp`

### Video pipeline

- [Video processor](https://github.com/k4yt3x/video2x/blob/master/src/libvideo2x.cpp): `src/libvideo2x.cpp`

### Processing engines

- [Processor factory](https://github.com/k4yt3x/video2x/blob/master/src/processor_factory.cpp): `src/processor_factory.cpp`
- [libplacebo filter](https://github.com/k4yt3x/video2x/blob/master/src/filter_libplacebo.cpp): `src/filter_libplacebo.cpp`
- [Real-ESRGAN filter](https://github.com/k4yt3x/video2x/blob/master/src/filter_realesrgan.cpp): `src/filter_realesrgan.cpp`
- [Real-CUGAN filter](https://github.com/k4yt3x/video2x/blob/master/src/filter_realcugan.cpp): `src/filter_realcugan.cpp`
- [RIFE interpolator](https://github.com/k4yt3x/video2x/blob/master/src/interpolator_rife.cpp): `src/interpolator_rife.cpp`

### Media support

- [Video decoder](https://github.com/k4yt3x/video2x/blob/master/src/decoder.cpp): `src/decoder.cpp`
- [Video encoder](https://github.com/k4yt3x/video2x/blob/master/src/encoder.cpp): `src/encoder.cpp`
- [Frame conversions](https://github.com/k4yt3x/video2x/blob/master/src/conversions.cpp): `src/conversions.cpp`
- [AV utilities](https://github.com/k4yt3x/video2x/blob/master/src/avutils.cpp): `src/avutils.cpp`
- [Filesystem utilities](https://github.com/k4yt3x/video2x/blob/master/src/fsutils.cpp): `src/fsutils.cpp`
- [Logging manager](https://github.com/k4yt3x/video2x/blob/master/src/logger_manager.cpp): `src/logger_manager.cpp`
- [Vulkan device support](https://github.com/k4yt3x/video2x/blob/master/tools/video2x/src/vulkan_utils.cpp): `tools/video2x/src/vulkan_utils.cpp`

### Other components

- **Video user**

## Connections

- Video user → Argument parsing: sets options (evidence: `tools/video2x/src/argparse.cpp`)
- Argument parsing → Option validators: validates values (evidence: `tools/video2x/src/argparse.cpp`)
- Argument parsing → CLI entry point: provides arguments (evidence: `tools/video2x/src/video2x.cpp`)
- CLI entry point → Video processor: starts processing
- Video processor → Video decoder: initializes decoder (evidence: `src/libvideo2x.cpp`)
- Video processor → Processor factory: creates processor (evidence: `src/libvideo2x.cpp`)
- Processor factory → libplacebo filter: creates filter (evidence: `src/processor_factory.cpp`)
- Processor factory → Real-ESRGAN filter: creates filter (evidence: `src/processor_factory.cpp`)
- Processor factory → Real-CUGAN filter: creates filter (evidence: `src/processor_factory.cpp`)
- Processor factory → RIFE interpolator: creates interpolator (evidence: `src/processor_factory.cpp`)
- Video processor → Video encoder: initializes encoder (evidence: `src/libvideo2x.cpp`)
- Video processor → libplacebo filter: filters frames (evidence: `src/libvideo2x.cpp`)
- Video processor → Real-ESRGAN filter: filters frames (evidence: `src/libvideo2x.cpp`)
- Video processor → Real-CUGAN filter: filters frames (evidence: `src/libvideo2x.cpp`)
- Video processor → RIFE interpolator: interpolates frames (evidence: `src/libvideo2x.cpp`)
- Video processor → Video encoder: writes frames (evidence: `src/libvideo2x.cpp`)
- libplacebo filter → Filesystem utilities: resolves resources (evidence: `src/filter_libplacebo.cpp`)
- Real-ESRGAN filter → Frame conversions: converts frames (evidence: `src/filter_realesrgan.cpp`)
- Real-CUGAN filter → Frame conversions: converts frames (evidence: `src/filter_realcugan.cpp`)
- RIFE interpolator → Frame conversions: converts frames (evidence: `src/interpolator_rife.cpp`)
- CLI entry point → Vulkan device support: selects device
