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.

Metadata

Release files for amverge 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for amverge 0.7.0
File Size Uploaded
amverge-0.7.0.tar.gz 2.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for amverge 0.7.0
File Interpreter ABI Platform
amverge-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.5 MB

Release files / amverge-0.7.0.tar.gz

Download URL amverge-0.7.0.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
ba3e223800e12f0e7e600426e0897e97697f8ddb773b82647819cedc20cfdcb7
BLAKE2b-256 checksum
How to use checksums
d893c3b2ec61c40ce4b543635fa776ba5395ab623305b88747126af1cc4d1080
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / amverge-0.7.0-py3-none-any.whl

Download URL amverge-0.7.0-py3-none-any.whl
Size 258.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0504a2870c9172d61c389ad3f911527ed489d0547f7fadcecc1dfc7c05f3c1cb
BLAKE2b-256 checksum
How to use checksums
3544e2a1b3bd51687408be1106a42ba751507fe06ea343ed232285a4b3961b4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.1

2 release files

This release

0.7.0 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page