# p0gdog/vcompress architecture

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

- Interactive diagram: https://gitdiagram.com/p0gdog/vcompress
- Repository: https://github.com/p0gdog/vcompress

## Overview

#### Purpose and Entry Point
vcompress is a Rust command-line utility that compresses MP4 video files toward a user-selected size budget, with configurable audio bitrate or complete audio removal. The sole application entry point is `src/main.rs`; Cargo defines the buildable/installable binary through `Cargo.toml`.

#### CLI Boundary
`src/main.rs` owns command-line argument parsing and user-facing behavior: input video selection, output path override, target size in MB, audio bitrate, and no-audio mode. It derives a default output name such as `example-compressed.mp4`, separating invocation parameters from media-processing execution.

Paths: `src/main.rs`, `Cargo.toml`

#### Compression Planning
The application converts the requested target file size and audio settings into an FFmpeg encoding plan. The key architectural responsibility is allocating the file-size budget between audio and video, including the no-audio path, then selecting video encoding parameters that aim to meet the target.

Paths: `src/main.rs`

#### External Media Execution
Actual probing and transcoding are delegated to the system-installed FFmpeg executable rather than embedded Rust codecs. vcompress constructs and executes FFmpeg commands against local input/output files; FFmpeg availability on `PATH` is therefore a runtime prerequisite and an important failure boundary.

Paths: `src/main.rs`, `README.md`

#### Runtime and Platform Model
The binary runs locally as a native Rust CLI on supported desktop platforms, including Linux and Windows per the release/install guidance. It operates on local MP4 paths and has no server, database, browser, or persistent application state. Rust provides process orchestration; FFmpeg provides media codec/container handling.

Paths: `Cargo.toml`, `src/main.rs`, `README.md`

#### Distribution and Release
Cargo supports crates.io installation, while GitHub Actions provides CI and release automation. Release artifacts are intended for direct download, and Arch Linux packaging is maintained separately through a PKGBUILD. The release script likely coordinates the repository’s publishing/release workflow.

Paths: `.github/workflows/ci.yml`, `.github/workflows/release.yml`, `scripts/release.sh`, `packaging/arch/PKGBUILD`

#### Control Flow
Execution is linear: parse CLI input → resolve output filename and encoding settings → calculate bitrate/size targets → invoke FFmpeg on the local source → report command outcome. The principal boundary is process execution: invalid inputs, missing FFmpeg, unsupported media, or FFmpeg failures must be surfaced back through the CLI.

Paths: `src/main.rs`

Main entry points: [`src/main.rs`](https://github.com/p0gdog/vcompress/blob/main/src/main.rs) (CLI Entry Point), [`.github/workflows/release.yml`](https://github.com/p0gdog/vcompress/blob/main/.github/workflows/release.yml) (Release Workflow), [`Cargo.toml`](https://github.com/p0gdog/vcompress/blob/main/Cargo.toml) (Cargo Package), [`scripts/release.sh`](https://github.com/p0gdog/vcompress/blob/main/scripts/release.sh) (Release Script)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Local Runtime"]
  node_cargo["Cargo Package<br/>Rust build manifest<br/>[Cargo.toml]"]
  node_cli["CLI Entry Point<br/>Rust binary<br/>[main.rs]"]
  node_input["Input MP4<br/>local media file"]
  node_output["Output MP4<br/>local media file"]
  node_output_resolution["Output Resolution<br/>CLI behavior<br/>[main.rs]"]
  node_encoding_plan["Encoding Plan<br/>bitrate planner<br/>[main.rs]"]
  node_ffmpeg{{"System FFmpeg<br/>external executable"}}
end

subgraph group_distribution["Distribution &amp; Release"]
  node_ci["CI Workflow<br/>GitHub Actions workflow<br/>[ci.yml]"]
  node_release_workflow["Release Workflow<br/>GitHub Actions workflow<br/>[release.yml]"]
  node_release_script["Release Script<br/>release automation<br/>[release.sh]"]
  node_crates["crates.io Install<br/>package distribution<br/>[Cargo.toml]"]
  node_release_artifacts["Release Artifacts<br/>downloadable binaries"]
  node_arch_package["Arch Package<br/>PKGBUILD packaging"]
end

node_cargo -->|"builds"| node_cli
node_input -->|"CLI input path"| node_cli
node_cli -->|"resolves output"| node_output_resolution
node_cli -->|"passes size and audio options"| node_encoding_plan
node_output_resolution -->|"output path"| node_ffmpeg
node_encoding_plan -->|"encoding arguments"| node_ffmpeg
node_input -->|"source media"| node_ffmpeg
node_ffmpeg -->|"transcoded MP4"| node_output
node_ffmpeg -.->|"process result or failure"| node_cli
node_ci -->|"builds and validates"| node_cargo
node_release_workflow -->|"runs"| node_release_script
node_release_script -->|"publishes"| node_crates
node_release_workflow -->|"creates"| node_release_artifacts
node_arch_package -.->|"packages release"| node_release_artifacts

click node_cargo "https://github.com/p0gdog/vcompress/blob/main/Cargo.toml"
click node_cli "https://github.com/p0gdog/vcompress/blob/main/src/main.rs"
click node_output_resolution "https://github.com/p0gdog/vcompress/blob/main/src/main.rs"
click node_encoding_plan "https://github.com/p0gdog/vcompress/blob/main/src/main.rs"
click node_ci "https://github.com/p0gdog/vcompress/blob/main/.github/workflows/ci.yml"
click node_release_workflow "https://github.com/p0gdog/vcompress/blob/main/.github/workflows/release.yml"
click node_release_script "https://github.com/p0gdog/vcompress/blob/main/scripts/release.sh"
click node_crates "https://github.com/p0gdog/vcompress/blob/main/Cargo.toml"
click node_arch_package "https://github.com/p0gdog/vcompress/blob/main/packaging/arch/PKGBUILD"

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_cargo,node_cli,node_input,node_output,node_output_resolution,node_encoding_plan,node_ffmpeg toneBlue
class node_ci,node_release_workflow,node_release_script,node_crates,node_release_artifacts,node_arch_package toneAmber
```

## Components

### Local Runtime

Native CLI processing on local MP4 files.

- [Cargo Package](https://github.com/p0gdog/vcompress/blob/main/Cargo.toml): Rust build manifest · Defines the buildable and installable binary. · `Cargo.toml`
- [CLI Entry Point](https://github.com/p0gdog/vcompress/blob/main/src/main.rs): Rust binary · Parses arguments and reports processing outcomes. · `src/main.rs`
- **Input MP4**: local media file
- **Output MP4**: local media file
- [Output Resolution](https://github.com/p0gdog/vcompress/blob/main/src/main.rs): CLI behavior · Derives or accepts the output filename. · `src/main.rs`
- [Encoding Plan](https://github.com/p0gdog/vcompress/blob/main/src/main.rs): bitrate planner · Allocates target size between audio and video, including no-audio mode. · `src/main.rs`
- **System FFmpeg**: external executable · Probes and transcodes media through a PATH-installed process.

### Distribution & Release

- [CI Workflow](https://github.com/p0gdog/vcompress/blob/main/.github/workflows/ci.yml): GitHub Actions workflow · `.github/workflows/ci.yml`
- [Release Workflow](https://github.com/p0gdog/vcompress/blob/main/.github/workflows/release.yml): GitHub Actions workflow · `.github/workflows/release.yml`
- [Release Script](https://github.com/p0gdog/vcompress/blob/main/scripts/release.sh): release automation · `scripts/release.sh`
- [crates.io Install](https://github.com/p0gdog/vcompress/blob/main/Cargo.toml): package distribution · `Cargo.toml`
- **Release Artifacts**: downloadable binaries
- [Arch Package](https://github.com/p0gdog/vcompress/blob/main/packaging/arch/PKGBUILD): PKGBUILD packaging · `packaging/arch/PKGBUILD`

## Connections

- Cargo Package → CLI Entry Point: builds
- Input MP4 → CLI Entry Point: CLI input path
- CLI Entry Point → Output Resolution: resolves output
- CLI Entry Point → Encoding Plan: passes size and audio options
- Output Resolution → System FFmpeg: output path
- Encoding Plan → System FFmpeg: encoding arguments
- Input MP4 → System FFmpeg: source media
- System FFmpeg → Output MP4: transcoded MP4
- System FFmpeg → CLI Entry Point: process result or failure
- CI Workflow → Cargo Package: builds and validates
- Release Workflow → Release Script: runs
- Release Script → crates.io Install: publishes
- Release Workflow → Release Artifacts: creates
- Arch Package → Release Artifacts: packages release
