Skip to main content

AMVerge CLI

Python PyPI License

AMVerge CLI

AMVerge Features as a CLI Tool and Python Library. Port of the AMVerge desktop app backend by Crptk. Split videos into scenes, export clips, merge fragments, and build your own tools on top of it.


Features

  • TransNetV2 ML detection - deep learning scene boundary detection (GPU/CPU)
  • Keyframe detection - fast I-frame based splitting, no re-encode
  • Edge detection - Canny edges + cosine similarity for difficult encodes
  • AI Upscaling - ShuffleCUGAN (ML), Anime4K (shaders), ArtCNN (ONNX) super-resolution
  • Frame Interpolation - Python RIFE (PyTorch CUDA/CPU) + Flowframes 1.42.0 integration (free 1.36.0 planned)
  • Depth Maps - per-frame monocular depth estimation via Depth-Anything-V2 (GPU/CPU)
  • Deadframe Removal - optical flow + ORB homography + motion-area analysis (OpenCV)
  • Pipeline - chain deadframes + upscale + interpolate, save/load presets, interactive or TUI
  • Smart cut - automatic lossless copy / smartcut / re-encode per scene
  • 15 codec profiles - H.264, HEVC, AV1, ProRes with hardware (NVENC) support
  • 10 audio codecs - AAC, FLAC, Opus, PCM, MP3, pass-through
  • 3 container formats - MP4, MKV, MOV (ProRes auto-enforces MOV)
  • Auto-generated scene thumbnails (progressive JPEG)
  • Duplicate / similar scene detection (cosine similarity)
  • Scene export with full codec + audio + hardware selection
  • Clip merging via FFmpeg concat
  • Video metadata inspection and diagnostics
  • TransNetV2 scene cache (.npy) - skip re-detection on re-open
  • Discord Rich Presence (same app ID as AMVerge desktop)
  • Interactive wizard mode (amverge with no args)
  • Fully usable as a Python library - 52 names from import amverge

Install

pip install amverge

See docs/installation.md for FFmpeg setup, optional dependencies, and dev install.


Quick Start

# Interactive wizard
amverge

# Direct commands
amverge detect episode.mp4
amverge export episode.mp4 --scenes episode_scenes/scenes.json --select 0,2,5-8
amverge merge clip1.mp4 clip2.mp4 --output out.mp4
amverge info episode.mp4
amverge upscale episode.mp4 --method ml --model adore -s 2
amverge upscale episode.mp4 --method anime4k --anime4k-mode medium
amverge models                           # manage upscale & interpolation model files
amverge interpolate episode.mp4 -f 2     # AI frame interpolation (RIFE, PyTorch)
amverge flowframes episode.mp4 -f 2      # frame interpolation via Flowframes 1.42.0 (free 1.36.0 planned)
amverge flowframes-path PATH             # configure Flowframes.exe location
amverge depth-map episode.mp4            # side-by-side depth visualization
amverge depth-map episode.mp4 --pred-only --grayscale  # grayscale depth map only
amverge deadframes episode.mp4            # remove static dead frames (CFR compaction)
amverge deadframes episode.mp4 --auto --safe  # auto-calibrate, only drop truly static
amverge pipeline                      # chain deadframes + upscale + interpolate
amverge pipeline --load my-preset     # load saved pipeline preset
amverge pipeline --list               # list saved presets
from amverge import detect_scenes

result = detect_scenes("episode.mp4")
for scene in result.scenes:
    print(scene.index, scene.start, scene.end, scene.path)

How It Works
amverge CLI  /  Python library
          ↓
    amverge package
           ↓
    PyAV  +  FFmpeg  +  PyTorch (optional)  +  ONNX (optional)

Detection: Keyframe mode extracts I-frame timestamps via PyAV packet demux. Edge mode decodes frames and compares Canny edge maps. TransNetV2 runs a deep CNN on 48x27 RGB frames (GPU auto-detected, CPU fallback).

Cutting: Scenes aligned to keyframes get lossless stream copy. Non-aligned scenes get smartcut (encode head + copy tail) or full re-encode. HEVC on CPU uses snapped-copy (nearest keyframe within 5s) to avoid slow re-encode.

Upscaling: Three methods. ML mode runs ShuffleCUGAN U-Net via PyTorch/spandrel. Anime4K applies GLSL shaders via FFmpeg libplacebo (no ML deps). ArtCNN infers ONNX models via onnxruntime. All cache weights to %APPDATA%/amverge/.

Thumbnails: Decoded via PyAV, resized to 960px, saved as progressive JPEG in parallel. Similarity: Adjacent thumbnails compared via cosine similarity on 8x8 pooled pixels.

Interpolation: RIFE PyTorch inference (CUDA/CPU) with mod-32 padded frames, encoded feature caching, and FFmpeg rawvideo pipe. Flowframes 1.42.0 external process integration with session log tailing and output discovery. Support for free Flowframes 1.36.0 is planned (delivery TBD - differs from 1.42.0 Patreon version).

Depth Maps: Depth-Anything-V2 per-frame monocular depth estimation. Small (24.8M), Base (97.5M), or Large (335.3M) model. Color or grayscale output, side-by-side or depth-only. Models auto-downloaded from AniSmooth-Models GitHub Releases. H.264 output via FFmpeg pipe with source audio mux.

Deadframe Removal: Detects and removes frames where the main subject does not move (static/dead frames). Uses Farneback dense optical flow, ORB feature matching with RANSAC homography to distinguish subject motion from camera motion, and motion-area analysis to reject transient foreground passers. Output is CFR-compacted: kept frames packed back-to-back, duration shortens. Safe to feed into frame interpolation. Auto-calibration mode, keep-talking/keep-camera/safe flags, and cadence smoothing for native animation holds.

Pipeline: Chains deadframe removal, AI upscaling, and frame interpolation into a single run. Interactive arrow-key prompts or full-screen Textual TUI. Save configurations as named presets for reuse. Detects installed extras and only shows available operations. After each step, choose whether to chain the output into the next operation or revert to the original input.


Repository Structure
AMVerge-CLI/
├── amverge/
│   ├── __init__.py              public exports: detect_scenes, DetectResult, Scene, DetectionMethod
│   ├── __version__.py           version string
│   ├── cli.py                   Typer app, registers commands, no-args -> wizard
│   ├── pipeline.py              high-level detect_scenes() API
│   ├── wizard.py                interactive session (no-args mode)
│   ├── ui.py                    shared Rich theme, console, banner, progress, table helpers
│   │
│   ├── commands/
│   │   ├── about/               about, credits, changelog, usage
│   │   ├── detection/           detect, bench, cache, scenes, keyframes
│   │   ├── export/              export, merge
│   │   ├── upscaling/           upscale, models
│   │   ├── interpolation/       interpolate, flowframes, flowframes-path
│   │   ├── depth/                depth-map
│   │   ├── deadframes/           deadframes
│   │   ├── pipeline/              pipeline
│   │   ├── info/                info, probe
│   │   ├── sidecar/             backend, rpc_server (hidden)
│   │   └── system/              doctor, gpu, version
│   │
│   └── core/                    pure logic, no CLI/Rich deps
│       ├── codec/               codec profiles, HEVC detection (codec_utils)
│       ├── cutting/             segmenter (V1), smart_cut (V2)
│       ├── detection/           keyframe, edge (V1), scene_detection, nelux_runtime (V2)
│       ├── discord/             Discord RPC integration
│       ├── image/               image cropping
│       ├── infra/               binaries, IPC, diagnostics
│       ├── keyframes/           keyframe extraction + alignment
│       ├── similarity/          cosine similarity pair detection
│       ├── thumbnails/          thumbnail generation + streaming
│       ├── transnet/            TransNetV2 constants
│       ├── upscaling/           ml, anime4k, artcnn, registry
│       ├── interpolation/       RIFE PyTorch inference, Flowframes 1.42.0 integration
│       ├── depth/                Depth-Anything-V2 monocular depth estimation
│       ├── deadframes/           deadframe removal via optical flow + ORB homography
│       ├── pipeline/              operation-chaining presets (JSON save/load)
│       ├── video/               probe_utils, scene_utils, video metadata
│       └── wrappers/            public class wrappers (AmvergeVideo, SceneDetector, etc.)
│
├── examples/                runnable Python scripts
│   ├── custom-pipeline/     full end-to-end pipeline
│   ├── cutting/             smart cut, ffmpeg segment
│   ├── depth/                  depth map examples
│   ├── detect/              keyframe, edge, TransNetV2 detection
│   ├── diagnostics/         GPU, CUDA, dependency versions
│   ├── discord-rpc/         Discord Rich Presence
│   ├── export/              copy, re-encode with profiles, merge
│   ├── info-probe/          stream metadata, diagnostics, HEVC check
│   ├── keyframes/           extraction + classification for cutting
│   ├── similarity/          adjacent scene similarity detection
│   └── thumbnails/          JPEG thumbnail generation
│
├── docs/                    markdown documentation
├── assets/                  GIF and image assets
├── pyproject.toml
├── README.md
└── AGENTS.md

Examples

Runnable Python scripts for every feature. Each with its own README:

Directory Description
detect/ keyframe, edge, TransNetV2 detection
export/ copy, re-encode with profiles, merge
info-probe/ stream metadata, probe diagnostics, HEVC check
keyframes/ extract timestamps, classify for cutting
cutting/ smart cut, ffmpeg segment, single scene
thumbnails/ JPEG thumbnail generation
similarity/ adjacent scene similarity detection
diagnostics/ GPU, CUDA, dependency versions
discord-rpc/ Discord Rich Presence
custom-pipeline/ full end-to-end custom pipeline
upscale/ ML / Anime4K / ArtCNN super-resolution
interpolation/ RIFE PyTorch + Flowframes 1.42.0 (free 1.36.0 planned)
depth/ Depth-Anything-V2 monocular depth estimation
pip install amverge[ml,edge,discord]
python examples/detect/01_basic_detect.py episode.mp4
python examples/custom-pipeline/full_pipeline.py episode.mp4

See the examples README for the full directory map.


Documentation
Installation Requirements, FFmpeg setup, optional deps, dev install
CLI Reference All commands, flags, and usage examples
Python Library API reference, return types, low-level modules
Detection Methods Keyframe vs edge vs TransNetV2, cut modes, tuning
Examples 20 runnable Python scripts in 10 categories
Contributing Project structure, guidelines, links
AI Setup How to train AI tools to work like you, not generically

AI Agents

An AGENTS.md file is included for AI coding assistants (OpenCode, Claude Code, Cursor, etc.).

Using AI without understanding the codebase is not recommended. Read the code, understand the architecture, then use the agents file if it saves you time.

The best approach is not to use a generic AI assistant - it is to train it to work like you. Teach it your conventions, your decisions, your style. Done right, the output looks like yours, not like a generic answer. See docs/ai-setup.md for a practical guide on how to do this.


Credits

Built by Moongetsu as a standalone port of the AMVerge backend.

AMVerge was created by Crptk. All core scene detection and clip management logic originates from the original AMVerge project.


License

AMVerge CLI is licensed under the GNU GPL v3.0.

Any derivative work must also be open-source under the same license.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amverge-0.4.0.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amverge-0.4.0-py3-none-any.whl (226.6 kB view details)

Uploaded Python 3

File details

Details for the file amverge-0.4.0.tar.gz.

File metadata

  • Download URL: amverge-0.4.0.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for amverge-0.4.0.tar.gz
Algorithm Hash digest
SHA256 fc32cb4de4fbf70b8a18c3ee0a3c33e4978b817fad2519658ebbcd334bf2ca17
MD5 bd8919eac4d95142db3f43e8691b8013
BLAKE2b-256 5a97d164e57e056f376446cfd9e79096256f20c8e967a397d9b08e0347ac6356

See more details on using hashes here.

Provenance

The following attestation bundles were made for amverge-0.4.0.tar.gz:

Publisher: publish.yml on AMVerge-team/AMVerge-CLI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amverge-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: amverge-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 226.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for amverge-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9299472e824edd254291319852d0acad9a82ee022c15b74bab118d926eab8dd
MD5 a1cbdf3077ced3fed4400009ec4ed5ac
BLAKE2b-256 3d42a48069d0556446e28a18ad01e3881367a2b4fb4acd8d572038f7ea83f665

See more details on using hashes here.

Provenance

The following attestation bundles were made for amverge-0.4.0-py3-none-any.whl:

Publisher: publish.yml on AMVerge-team/AMVerge-CLI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page