AI-FFmpeg-CLI is a command-line utility that leverages AI to translate natural language descriptions into complex FFmpeg commands. You no longer need to memorize arcane syntax; simply describe what you want to achieve, and the tool handles the rest.
Key Features:
Before:
ffmpeg -i input.mp4 -vf "scale=1280:720" -c:v libx264 -c:a aac -b:v 2000k output.mp4
Now:
aiclip "convert input.mp4 to 720p with good quality"
Install via PyPI:
pip install ai-ffmpeg-cli
You can configure your OpenAI API key in two ways:
export OPENAI_API_KEY="sk-your-key-here"
.env file:echo "OPENAI_API_KEY=sk-your-key-here" > .env
Interactive Mode – Simply type aiclip. This opens a welcome screen showing media files in the current folder and current output settings. Enter your request, review the generated command, and confirm to run.
One-Shot Command – Execute tasks directly without entering the interactive shell. For example, to preview a compression command:
aiclip --dry-run "convert input.mp4 to 720p with good quality"
aiclip "convert input.mov to mp4 with h264 and aac"aiclip "downscale video.mp4 to 720p" or aiclip "make input.mp4 1080p resolution"aiclip "compress large-video.mp4 to a smaller size" or aiclip "reduce file size with CRF 23"aiclip "convert input.mp4 to animated gif" or aiclip "create a 5 second animated gif from video.mp4"aiclip "extract audio from movie.mp4 to mp3" or aiclip "get audio track from video as wav"aiclip "remove audio from video.mp4"aiclip "trim the first 30 seconds from video.mp4"aiclip "keep the segment from 2:15 to 3:45 in input.mp4"aiclip "cut out the middle 5 minutes"aiclip "create a thumbnail at 10 seconds from video.mp4" or aiclip "extract frame at 2:30 as PNG"aiclip "extract one frame every 5 seconds" or aiclip "get all frames from video as images"aiclip "add watermark logo.png to top-right of video.mp4" or aiclip "overlay text on video at position 10:10"aiclip "convert all .mov files to .mp4"| Action | Command |
|---|---|
| Run a one-shot command | aiclip "your request here" |
| Skip confirmation prompts | aiclip --yes "convert video.mp4 to 720p" |
| Preview the command only | aiclip --dry-run "compress input.mp4" |
| Select a specific AI model | aiclip --model gpt-4o-mini "extract audio" |
| Set a longer timeout | aiclip --timeout 120 "complex task" |
| Enable verbose logging | aiclip --verbose "your command" |
| Set a custom output directory | aiclip --output-dir /path/to/output "convert video.mp4 to 720p" |
You can also use the nl (natural language) subcommand. Global flags should be placed before the subcommand:
aiclip --yes nl "thumbnail at 10s from test.mp4"
aiclip --dry-run --model gpt-4o-mini nl "compress input.mp4"
Note: Avoid repeating the command name (e.g., do not use aiclip aiclip --yes nl).
Configure the tool using environment variables or a .env file.
Required:
OPENAI_API_KEY=sk-your-openai-api-keyOptional:
AICLIP_MODEL=gpt-4o – Specifies the AI model.AICLIP_DRY_RUN=false – Enables preview mode by default.AICLIP_OUTPUT_DIR=aiclip – Sets the default output directory.-c copy whenever possible for lossless, instant cutting.The tool maintains a clean workspace by organizing your files:
./aiclip/ (e.g., ./aiclip/video_720p.mp4).aiclip --output-dir /path/to/output "convert video.mp4 to 720p" results in /path/to/output/video_720p.mp4.export AICLIP_OUTPUT_DIR=my_outputs will direct all results to ./my_outputs/.Keeping generated files separate prevents clutter in your source folders and makes it easier to track project assets.
Every operation provides an immediate summary of token consumption and estimated cost:
aiclip> convert video.mp4 to 720p
📊 parse_intent: 2,073 → 47 (2,120 total) | $0.0057
In interactive mode, type tokens to view a comprehensive session summary:
Token Usage Summary
┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Metric ┃ Value ┃ Details ┃
┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Session ID ┃ a1b2c3d4 ┃ Started at 14:30:15 │
│ Duration ┃ 45.2s ┃ Session duration │
│ Operations ┃ 3 ┃ Total operations performed │
│ Input Tokens ┃ 6,142 ┃ Total tokens sent to AI │
│ Output Tokens ┃ 156 ┃ Total tokens received from AI │
│ Total Tokens ┃ 6,298 ┃ Combined input + output │
│ Estimated Cost ┃ $0.0171 ┃ Based on OpenAI pricing │
└────────────────┴──────────┴───────────────────────────────┘
A summary is also displayed automatically upon exiting the session.
The tool supports a variety of time formats:
"5 second", "10s", "30 seconds""2:30", "1:45:30", "00:02:15""5 second duration", "10 second clip"Examples:
aiclip "convert video.mp4 to a 5 second animated gif"aiclip "extract the first 30 seconds from video.mp4"aiclip "extract a frame at 2:30 from video.mp4"| Operation | Example Description | FFmpeg Equivalent |
|---|---|---|
| Format Conversion | "convert to mp4" | -c:v libx264 -c:a aac |
| Resizing | "scale to 720p" | -vf scale=1280:720 |
| Compression | "reduce size" | -c:v libx265 -crf 28 |
| Audio Extraction | "save as mp3" | -q:a 0 -map a |
| Trimming | "2:15 to 3:45" | -ss 00:02:15 -to 00:03:45 |
| Thumbnails | "frame at 10s" | -ss 00:00:10 -vframes 1 |
| Overlays | "watermark top-right" | -filter_complex overlay=W-w-10:10 |
| Batching | "all *.mov files" | Shell loop via wildcards |
| GIF Creation | "animated gif" | Optimized palette filters and -c:v gif |
To contribute to the project or run a local build, use the following commands:
git clone https://github.com/d-k-patel/ai-ffmpeg-cli.git
cd ai-ffmpeg-cli
make setup # Install dependencies
make test # Run the test suite
make lint # Check code quality
make demo # Run a demonstration
brew install ffmpegsudo apt install ffmpeg"OPENAI_API_KEY is required"
Ensure your key is exported to your environment or defined in a .env file.
"ffmpeg not found in PATH" Verify that FFmpeg is installed and your system can locate it.
"Failed to parse natural language prompt"
Try making your request more specific. Using a more capable model like gpt-4o or increasing the --timeout value may also help.
"No input files found" Confirm that the media file is in your current working directory and that the file extension is correct.
"Duration not applied to GIF/video" Use explicit phrasing, such as "5 second animated gif" or "10 second clip," to ensure the AI correctly identifies the duration parameter.
ReCode: Recursive Code Generation for LLM Agents
LightlyStudio: Reduce Annotation Costs Through Intelligent Data Curation
How to Install Open Notebook: A Guide for Docker and Source Setup
RunAgent: Build AI Agents in Python, Invoke Them Natively from Any Language
ShareGPT-4o-Image & Janus-4o: Open-Source Models Reaching GPT-4o Output Quality
Trae Agent: Run Complex Dev Workflows With Plain English Prompts
How to Install and Use Vosk Offline Speech Recognition
TensorZero: Optimize LLM Applications with Production Feedback
Memos Self-Hosted Note App: Lightweight Markdown and API-First
Teable: The Self-Hosted, PostgreSQL-Based Airtable Alternative
AI Peer Review Tool for Neuroscience: LLM-Driven Meta-Review Framework
Shendeng VPN: Unlimited Bandwidth, Smart Routing & VIP Membership (¥28/Month)