Video Toolkit (video/)
Fast, lossless (zero-reencode) video container and audio/subtitle track manipulation toolkit for single files or batch media libraries.
Why MKVToolNix + FFmpeg?
- Zero re-encoding: Video, audio, and subtitle bitstreams are copied directly at disk I/O speed rather than decoded and re-encoded.
- MKVToolNix (
mkvmerge,mkvextract,mkvpropedit): Default backend for.mkv,.mka,.mks,.mk3d, and.webm. Handles complex subtitle formats (SRT, ASS, SSA, PGS/SUP, VobSub), chapters, attachments, and instant in-place header/flag edits viamkvpropedit. - FFmpeg (
ffmpeg -c copy,ffprobe): Automatic backend for.mp4,.mov,.avi,.m4v,.ts,.m2ts, etc., or fallback when MKVToolNix is not installed. Bundlesstatic-ffmpegso FFmpeg/FFprobe work out of the box even without a system FFmpeg install. - Safe & Automatable: Defaults to writing
<stem>.edited<ext>instead of overwriting inputs, supports--dry-runcommand previews, atomic--in-placereplacement, parallel batch workers (-j/--jobs), terminal progress bars, and structured--jsoninspection.
Installation & Backend Setup
Install via PyPI or ai-toolkit
# Install directly from PyPI
pip install sanchousf-ai-toolkit-video
# Or via the AI-Toolkit manager CLI
ai-toolkit install video
# Or editable install from a repository checkout
pip install -e video/
This provides the video and video-tracks console scripts (you can also run python -m video ... directly).
Check or Install Native Backends (video setup)
FFmpeg is available automatically via the bundled static-ffmpeg dependency (or your system PATH / FFMPEG_HOME). For full Matroska support and instant in-place set-flags edits, check or install MKVToolNix:
# Check detected MKVToolNix and FFmpeg binary paths
video setup --check
# Automatically install MKVToolNix via your system package manager (winget/scoop/choco/brew/apt/dnf/pacman)
video setup --install-mkvtoolnix
You can also override binary locations per command with --mkvtoolnix-dir / --ffmpeg-dir, or via MKVTOOLNIX_HOME / FFMPEG_HOME.
Quick Start
1. Inspect Tracks (video tracks info)
# Inspect a single file or recursively scan a library
video tracks info movie.mkv
video tracks info ./movies --recursive --json
2. Add Audio or Subtitle Tracks (video tracks add)
# Add a single subtitle or audio track without re-encoding
video tracks add movie.mkv --track movie.en.srt --lang eng --default
# Sync-adjust an added audio track (+250 ms)
video tracks add movie.mkv --track commentary.ac3 --lang eng --name "Director Commentary" --delay-ms 250
# Batch-add matching sidecar files (Movie.en.srt, Movie.spa.forced.ass, Movie.ac3, etc.)
# Automatically detects non-Latin subtitle scripts when filenames omit language tags
video tracks add ./movies --auto-sidecars --in-place --jobs 4
# Pull sidecars from subfolders with per-extension or path-glob metadata rules (supports {parent})
video tracks add ./movies --auto-sidecars \
--sidecar-dir "Rus Sound" --sidecar-dir "RUS Subs" --sidecar-recursive \
--sidecar-rule "[AniMedia]/*.mka:lang=rus,name=Russian ({parent}),default=no" \
--sidecar-rule ".ass:lang=rus,name=Russian (ASS),default=yes" \
--output-dir ./merged --jobs 4
3. Extract Tracks (video tracks extract)
# Extract all audio & subtitle tracks from a file
video tracks extract movie.mkv
# Filter by track type, language, or track ID across a folder
video tracks extract ./movies --type subtitles --lang eng,spa --output-dir ./subs --jobs 4
video tracks extract movie.mkv --id 1,2 --output-dir ./extracted
4. Remove Tracks (video tracks remove)
# Strip all subtitles into a new file
video tracks remove movie.mkv --no-subtitles --output movie.clean.mkv
# Keep only English audio/subtitle tracks in-place across a folder (preserving video)
video tracks remove ./movies --keep-lang eng --in-place --jobs 4
5. Edit Track Flags In-Place (video tracks set-flags)
Updates MKV headers instantaneously via mkvpropedit without remuxing:
# Update a single track's language, title, and default/forced flags
video tracks set-flags movie.mkv --id 1 --lang eng --name "English 5.1" --default --no-forced
# Update multiple tracks in one pass across a folder using repeatable --spec
video tracks set-flags ./movies \
--spec "1:lang=jpn,name=Japanese (FLAC),default=yes" \
--spec "2:lang=eng,name=English (AAC),default=no" \
--spec "3:lang=rus,name=Russian (ASS),default=yes"
6. Sample Audio for Language Verification (video tracks sample)
Cut a short lossless audio-only .mka clip from a file to verify an untagged track's spoken language:
video tracks sample movie.mkv --id 2 --start 00:01:00 --duration 45 --output sample.mka
7. Preview Commands (--dry-run) & Backend Selection
Add --dry-run to any modifying command (add, extract, remove, set-flags, sample) to print the exact mkvmerge / mkvextract / mkvpropedit / ffmpeg commands without modifying files. Use --backend auto|mkvtoolnix|ffmpeg to override backend selection and --no-progress to disable the terminal progress bar.
8. Install Bundled AI Agent Skills (video --install-skills)
# Install bundled `video-tool` skill into the workspace (.agents/skills/)
video --install-skills
# Install globally for a specific AI agent (antigravity, claude, cursor, windsurf, copilot)
video --install-skills global --agent claude
# List available bundled skills or supported agents
video install-skills --list-skills
video install-skills --list-agents
Python API (video.core.operations)
from pathlib import Path
from video.core.models import TrackAddition
from video.core.operations import (
add_tracks,
extract_tracks,
inspect_target,
remove_tracks,
sample_audio,
set_track_flags,
)
infos = inspect_target(Path("movie.mkv"))
add_tracks(
Path("movie.mkv"),
tracks=[TrackAddition(path=Path("movie.en.srt"), language="eng", default=True)],
in_place=True,
)
Directory Structure
video/
├── pyproject.toml # `sanchousf-ai-toolkit-video` package metadata & console scripts
├── cli.py # Unified `video` CLI entrypoint (`tracks`, `setup`, `install-skills`)
├── tracks.py # `video-tracks` CLI entrypoint
├── pytest.ini # Pytest configuration
├── core/
│ ├── backends.py # MKVToolNix & FFmpeg lossless command builders and parsers
│ ├── discovery.py # Tool discovery, sidecar matching, script/language detection & rules
│ ├── models.py # Dataclasses (`MediaInfo`, `TrackInfo`, `TrackAddition`, `OperationResult`)
│ ├── operations.py # High-level batch & single-file operations API
│ └── progress.py # Terminal progress bar & stdout progress parsers
├── skills/ # Bundled `video-tool` AI agent skill & installer
├── ci/
│ └── action.yml # GitHub Actions composite action for Video
└── tests/ # Unit & CLI tests
Running Tests & CI
cd video
pip install -e ".[test]"
pytest -v --cov=core --cov-report=term-missing
Continuous Integration is configured in .github/workflows/video.yml using ci/action.yml, running on Ubuntu (plus Windows on pull requests targeting main, and optionally macOS via workflow_dispatch with run_full: true) with HTML and Codecov coverage uploads.
Metadata
Release files for sanchousf-ai-toolkit-video 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sanchousf_ai_toolkit_video-0.1.1.tar.gz | 39.8 kB | With provenance | Details for sanchousf_ai_toolkit_video-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sanchousf_ai_toolkit_video-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for sanchousf_ai_toolkit_video-0.1.1-py3-none-any.whl |
Total release size: 78.8 kB
Release files / sanchousf_ai_toolkit_video-0.1.1.tar.gz
| Download URL | sanchousf_ai_toolkit_video-0.1.1.tar.gz |
|---|---|
| Size | 39.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea410ad933cc5d8022739cb0ecb3c1a53d6ca7c80a693eb5e32fff8f88457d1a
|
|
BLAKE2b-256 checksum How to use checksums |
271fc2b41b4dd785a908fcab75f2fa80f3f5ebb1de76a5ae86346202dafb4be4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 30, 2026.
Transparency logRelease files / sanchousf_ai_toolkit_video-0.1.1-py3-none-any.whl
| Download URL | sanchousf_ai_toolkit_video-0.1.1-py3-none-any.whl |
|---|---|
| Size | 39.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3624cf3e9ee784acc8d4485f9afc3de0d6a59ed4aa3898ddbde0e2845adc641f
|
|
BLAKE2b-256 checksum How to use checksums |
adce3dafc15ab0107f4e62ded28b1d95ad937f0fee7718666c33fe26f26cb71c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 30, 2026.
Transparency logSecurity for sanchousf-ai-toolkit-video 0.1.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sanchousf_ai_toolkit_video-0.1.1.tar.gz
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 Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.