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.4.tar.gz (111.1 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.4-py3-none-any.whl (121.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mediallm-0.0.4.tar.gz
  • Upload date:
  • Size: 111.1 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.4.tar.gz
Algorithm Hash digest
SHA256 ae803fdcdf1f2a158137728d4f1cd777da551fccca1f1ced67a262f55a3a0240
MD5 6eb156c68cd93e6830b4105e34477499
BLAKE2b-256 9b4e5dba4338eaba4c52c96b6ca19854c3e2cfdb98b9867bbaec8185793f1f58

See more details on using hashes here.

Provenance

The following attestation bundles were made for mediallm-0.0.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: mediallm-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 121.1 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4400e79ad3d3028c7151376e6c16284c7ca5d38757004c2f884568e6474dd699
MD5 6c4da4387dcd4d535f0e1eefa26395e6
BLAKE2b-256 81f742bba1d2a0e9d1b190356592c074a59980bae2388b6246b8d96267465525

See more details on using hashes here.

Provenance

The following attestation bundles were made for mediallm-0.0.4-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