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


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.1.tar.gz (162.4 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.1-py3-none-any.whl (110.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mediallm-0.0.1.tar.gz
Algorithm Hash digest
SHA256 877df186a5d5ba9c069f1e0d5539b641b59977a8999e1269438756dbd9b72724
MD5 cd79a7805b97f3a6003b7183586f9097
BLAKE2b-256 bc6c0b9888ea3d5bf6aacd70141f81284fb3ee2d1e3623353c036a281387a9b5

See more details on using hashes here.

Provenance

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

Publisher: publish.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.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for mediallm-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c44ffa4cecddc09e4e3b799e61c5ad25dfcb877ddc6d6614ef8415b3a97205e1
MD5 d28f168dd7dc41ae66baa218a66a5df9
BLAKE2b-256 0ff4b19eb6580a05e292e5322d7cc707e6e02da111c061781cfa5919e52d3294

See more details on using hashes here.

Provenance

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

Publisher: publish.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