Skip to main content

Natural language to FFmpeg, instantly and privately

Project description

███╗   ███╗███████╗██████╗ ██╗ █████╗ ██╗     ██╗     ███╗   ███╗
████╗ ████║██╔════╝██╔══██╗██║██╔══██╗██║     ██║     ████╗ ████║
██╔████╔██║█████╗  ██║  ██║██║███████║██║     ██║     ██╔████╔██║
██║╚██╔╝██║██╔══╝  ██║  ██║██║██╔══██║██║     ██║     ██║╚██╔╝██║
██║ ╚═╝ ██║███████╗██████╔╝██║██║  ██║███████╗███████╗██║ ╚═╝ ██║
╚═╝     ╚═╝╚══════╝╚═════╝ ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝

Natural language to FFmpeg, instantly and privately

PyPI version Python 3.10+ License: MIT

Full Documentation


Quick Start

Install MediaLLM:

pip install mediallm

Setup prerequisites:

# Install Ollama (local LLM)
curl -fsSL https://ollama.com/install.sh | sh
ollama serve
ollama pull llama3.1:latest

# Install FFmpeg
brew install ffmpeg  # macOS
# sudo apt install ffmpeg  # Linux

CLI Usage

# Convert video to audio
mediallm "convert video.mp4 to MP3 audio"

# Resize and compress
mediallm "compress large_video.mp4 to 720p"

# Create GIF from video
mediallm "create 10-second GIF from video.mp4 starting at 1 minute"

# Preview command (dry-run)
mediallm --dry-run "extract audio from movie.avi"

Python API Usage

Basic Usage

import mediallm

# Initialize MediaLLM
ml = mediallm.MediaLLM()

# Generate FFmpeg commands from natural language
commands = ml.generate_command("convert video.mp4 to high-quality MP3")
print("Generated commands:", commands)

# Scan workspace for media files
workspace = ml.scan_workspace()
print(f"Found {len(workspace.get('videos', []))} videos")

Advanced Usage

import mediallm

# Scan directory for media files
workspace = mediallm.discover_media()
print(f"Found {len(workspace.get('videos', []))} videos")

# Initialize with custom settings
ml = mediallm.MediaLLM(
    workspace=workspace,
    model_name="llama3.1:latest", 
    ollama_host="http://localhost:11434",
    timeout=120
)

# Generate commands from natural language
commands = ml.generate_command("compress large_video.mp4 to 720p")
print("Commands:", commands)

Using Data Models

import mediallm
from pathlib import Path

# Create MediaIntent objects directly
intent = mediallm.MediaIntent(
    action=mediallm.Action.convert,
    inputs=[Path("input.mp4")],
    video_codec="libx264",
    audio_codec="aac"
)

# Available actions
for action in mediallm.Action:
    print(f"- {action.value}")

Configuration

Create a .env file or set environment variables:

MEDIALLM_MODEL=llama3.1:latest
MEDIALLM_OLLAMA_HOST=http://localhost:11434
MEDIALLM_OUTPUT_DIR=./outputs
MEDIALLM_DRY_RUN=false

Contributing

We welcome contributions! See our contributing guide for:

  • Development setup
  • Testing guidelines
  • Code style requirements
  • How to submit pull requests

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

mediallm-0.0.3.tar.gz (96.7 kB view details)

Uploaded Source

Built Distribution

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

mediallm-0.0.3-py3-none-any.whl (111.3 kB view details)

Uploaded Python 3

File details

Details for the file mediallm-0.0.3.tar.gz.

File metadata

  • Download URL: mediallm-0.0.3.tar.gz
  • Upload date:
  • Size: 96.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mediallm-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f556710a63d8b10bbd3a3ebf117cc61a20c1aaf94b9cce9ef5bc926c81ade7b5
MD5 661d1c81d51fde7a6e68d0ff67d3f881
BLAKE2b-256 db73856b444fb2d04c8ecfcfc548a4b7d58c9bbfc1ee7b7ccc25386deb303dc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mediallm-0.0.3.tar.gz:

Publisher: publish-mediallm.yml on iamarunbrahma/mediallm

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

File details

Details for the file mediallm-0.0.3-py3-none-any.whl.

File metadata

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

File hashes

Hashes for mediallm-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c90cd5ea81f7bb042764a93043cbcb00e641a695719394e7520c21e191ae4f96
MD5 eaa6ceea07871c5201fae12bb05a154f
BLAKE2b-256 9997fe429d5cb06ce11e7ae168559c4a0266896096a57a7448e768923fa27489

See more details on using hashes here.

Provenance

The following attestation bundles were made for mediallm-0.0.3-py3-none-any.whl:

Publisher: publish-mediallm.yml on iamarunbrahma/mediallm

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