Skip to main content

AI video toolkit - detect, analyze, and work with AI-generated videos

Project description

aivid

AI video toolkit - detect, analyze, and work with AI-generated videos

PyPI version Python versions License: MIT CI

Features

  • AI Detection: Detect AI-generated videos through C2PA metadata and heuristic analysis
  • C2PA Signing: Add C2PA manifests to media files (requires c2patool)
  • Metadata Extraction: Extract comprehensive metadata from video files
  • Multi-tool Support: Leverages ffprobe, mediainfo, exiftool, and c2patool for thorough analysis
  • MP4 Box Analysis: Binary parsing of MP4/MOV container structure
  • Software Detection: Identify editing software (FFmpeg, Adobe, DaVinci, OBS, etc.)
  • Multiple Output Modes: Default summary, full details, C2PA focus, or quiet mode
  • JSON Export: Export reports for automation and integration
  • Batch Processing: Analyze multiple files with single command

Supported AI Generators

Generator Detection Method Confidence
OpenAI Sora C2PA manifest + 96kHz audio signature High
OpenAI DALL-E C2PA manifest High
Google Gemini/Veo Encoder tag + C2PA manifest High
Adobe Firefly C2PA manifest High
Midjourney C2PA manifest High
Stability AI C2PA manifest High
Runway C2PA manifest Medium
Pika Labs C2PA manifest Medium
Kling AI C2PA manifest Medium
Luma AI Handler name + C2PA manifest Medium

Requirements

System Dependencies

aivid requires these command-line tools to be installed:

  • ffprobe (required) - Part of FFmpeg
  • mediainfo (optional, recommended)
  • exiftool (optional, recommended)
  • c2patool (optional) - For accurate C2PA manifest parsing and signing

macOS

brew install ffmpeg mediainfo exiftool

Ubuntu/Debian

sudo apt-get install ffmpeg mediainfo exiftool

Windows

# Using Chocolatey
choco install ffmpeg mediainfo exiftool

# Or using Scoop
scoop install ffmpeg mediainfo exiftool

Install c2patool (optional)

c2patool provides more accurate C2PA manifest parsing and signing capabilities.

# Using Cargo (Rust package manager)
cargo install c2patool

# Or download prebuilt binaries from:
# https://github.com/contentauth/c2pa-rs/releases

Python Installation

pip install aivid

Or with uv:

uv pip install aivid

Quick Start

Command Line

# Basic analysis
aivid video.mp4

# AI detection focus (C2PA mode)
aivid --c2pa video.mp4

# Full metadata details
aivid --full video.mp4

# Quick summary for multiple files
aivid -q *.mp4

# Export to JSON
aivid -o report.json video.mp4

# Sign a file with C2PA manifest (requires c2patool)
aivid --sign manifest.json -o signed_video.mp4 video.mp4

Python API

from aivid import analyze_file, check_c2patool_available, sign_with_c2pa, MetadataReport

# Analyze a video file
report = analyze_file("video.mp4")

# Check if AI-generated
if report.is_ai_generated:
    print(f"AI Generator: {report.ai_generator}")

# Access metadata
print(f"Duration: {report.container_info.get('duration')}s")
print(f"Resolution: {report.encoding_info['video']['width']}x{report.encoding_info['video']['height']}")

# C2PA information
if report.c2pa_info:
    print(f"C2PA Manifest: {report.c2pa_info.get('manifest_id')}")
    print(f"Signing Authority: {report.c2pa_info.get('signing_authorities')}")

# Sign a file with C2PA manifest (requires c2patool)
if check_c2patool_available():
    sign_with_c2pa(
        input_path="video.mp4",
        output_path="signed_video.mp4",
        manifest_path="manifest.json"
    )

Output Modes

Default Mode

Basic metadata with file info, container details, encoding info, and C2PA summary.

aivid video.mp4

C2PA Mode (--c2pa)

Focused on AI content detection with indicators and confidence levels.

aivid --c2pa video.mp4

Output includes:

  • C2PA manifest detection
  • AI generation indicators (audio sample rate, encoder tags, etc.)
  • Detection summary with confidence levels

Note: When c2patool is installed, aivid uses it for more accurate C2PA parsing.

Full Mode (--full)

Complete metadata dump including mediainfo, exiftool, all streams, and raw data.

aivid --full video.mp4

Quiet Mode (-q)

One-line summary per file, ideal for batch processing.

aivid -q *.mp4

Sign Mode (--sign)

Add a C2PA manifest to a media file (requires c2patool).

# Create a manifest file
cat > manifest.json << 'EOF'
{
  "claim_generator": "aivid",
  "title": "My Video",
  "assertions": [
    {
      "label": "c2pa.actions",
      "data": {
        "actions": [{"action": "c2pa.edited"}]
      }
    }
  ]
}
EOF

# Sign the video
aivid --sign manifest.json -o signed_video.mp4 video.mp4

# Verify the signature
aivid --c2pa signed_video.mp4

Development

Setup

# Clone the repository
git clone https://github.com/SocialNetwork0/aivid.git
cd aivid

# Create virtual environment and install dependencies
uv venv
uv pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

Local CLI usage for testing (方法 2,本地 CLI 测试)

方便本地从源码仓库里直接跑 aivid 命令做测试(你现在用的就是这种方式)

cd /Users/yuanlu/Code/ai-video-tools

# 1. 创建并激活虚拟环境(只需创建一次,之后每次只需激活)
uv venv
source .venv/bin/activate  # macOS / Linux

# 2. 以开发模式安装当前仓库(代码改动会立刻反映到 CLI)
uv pip install -e ".[dev]"

# 3. 在这个虚拟环境里使用 aivid 命令进行测试
aivid --help

# 示例:对 data 目录下的视频做一次基础分析
aivid data/sora_video/19700121_0310_69650d0aeaec8191bdb986a1b9b2a84f.mp4

Running Tests

uv run pytest

Code Quality

# Linting
uv run ruff check .

# Formatting
uv run ruff format .

# Type checking
uv run mypy src

Supported File Formats

Native MP4/MOV parsing: .mp4, .m4v, .m4a, .mov, .3gp, .3g2

Other formats: Any format supported by ffprobe

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE for details.

Acknowledgments

  • C2PA - Coalition for Content Provenance and Authenticity
  • c2patool - C2PA command line tool
  • FFmpeg - Multimedia framework
  • MediaInfo - Media file analysis
  • ExifTool - Metadata extraction

Project details


Download files

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

Source Distribution

aivid-0.2.0.tar.gz (36.6 MB view details)

Uploaded Source

Built Distribution

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

aivid-0.2.0-py3-none-any.whl (35.6 kB view details)

Uploaded Python 3

File details

Details for the file aivid-0.2.0.tar.gz.

File metadata

  • Download URL: aivid-0.2.0.tar.gz
  • Upload date:
  • Size: 36.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aivid-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0cab3f01cdfda2c1e4bdd856715002b075dbfe8ab568b1d69c03e20d0d5e958a
MD5 c34653f813ed54bb2956c83d93151b94
BLAKE2b-256 490614cb77cc6d93d5bae752822c74dfe12017fb2abfd003e1f1a87cdf12db63

See more details on using hashes here.

Provenance

The following attestation bundles were made for aivid-0.2.0.tar.gz:

Publisher: ci.yml on socialnetwork0/aivid

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

File details

Details for the file aivid-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: aivid-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aivid-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b0e76e50018b9bd9c111dc160535e85807278470db278e11acc88e2530a902a
MD5 35fde22da9f32e3665ba1b3428d84968
BLAKE2b-256 e4b6da772854455545f9f1c5a7a165814487005894dcc09c327f484bf00032e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for aivid-0.2.0-py3-none-any.whl:

Publisher: ci.yml on socialnetwork0/aivid

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 Pingdom Monitoring Sentry Error logging StatusPage Status page