A CLI tool featuring a localhost web interface for visually determining FFmpeg crop coordinates of any media file.
Project description
✂️ MediaCrop - The Visual FFmpeg Crop Tool
🧩 Overview
MediaCrop is a modern, lightweight, web-based utility that eliminates the guesswork from cropping media using FFmpeg. It offers a clean, intuitive visual interface to obtain precise crop coordinates for any video, image, or audio file. Simply drag, resize, or type in coordinates to instantly generate your perfect FFmpeg crop string.
The tool launches a local web server and automatically opens a sleek, responsive browser interface, complete with Light & Dark themes, ensuring a fast, enjoyable, and efficient experience tailored to your preferences.
📖 The Story Behind MediaCrop
Working with FFmpeg provides immense power, but it is rarely intuitive—especially when identifying accurate crop coordinates. Traditionally, this process involved a tedious, repetitive cycle:
- Opening the file in a media player.
- Estimating coordinates visually by trial and error.
- Running the FFmpeg command to test the crop.
- Reviewing the result and iterating on the coordinates.
This endless loop consumed valuable time and energy. MediaCrop was created to break this cycle, offering a visual, drag-and-drop, and type-in solution that delivers command-line-ready FFmpeg filter strings instantly. No more trial and error. No more frustration. Just precision made effortless.
✨ Key Features
| Category | Feature | Description |
|---|---|---|
| Interface & UX | 🌌 Light & Dark Themes | Seamlessly switch themes. Auto-detects OS preference on first load and saves your choice in local storage. |
| 🖼️ Resizable Live Preview | Real-time preview in a floating, draggable window. Features 8 resize handles, pinch-to-zoom, and long-press to fullscreen. | |
| 📱 Responsive Design | Automatically adapts to all screen sizes—desktop, tablet, and mobile devices. | |
| 🖐️ Native Touch Experience | Full touch support with gestures like double-tap to zoom, pinch-to-zoom, and subtle haptic feedback on key actions. | |
| 💾 State Persistence | Automatically saves your crop position and zoom level in your browser. Refreshing the page won't lose your work. | |
| 🔔 Custom Notifications | Clean, non-blocking notifications appear on save actions, replacing intrusive browser alerts. | |
| Media Handling | ⏯️ Full Video Controls | Comprehensive controls including play/pause, seek bar, playback speed adjustment, time display, and volume/mute options. |
| 🎵 Broad Format Support | Previews a wide range of image, video, and audio formats, with graceful fallbacks for unsupported files. | |
| Precision Tools | 📊 Bi-directional Info Panel | Type exact 'Preview' or 'Actual' coordinates. Now supports click-and-drag "scrubbing" on labels (X, Y, W, H) for rapid adjustment. |
| 📐 Aspect Ratio Presets | Select standard ratios like 16:9, 4:3, 9:16, 1:1 or input a custom ratio. | |
| 🔒 Keep Aspect Ratio Toggle | Dedicated checkbox to lock the crop box's aspect ratio during resizing. | |
| 🔎 Advanced Zoom & Pan | Zoom in/out with the mouse wheel or pinch. Pan the zoomed media using Alt + Drag, middle-mouse drag, or one-finger drag on mobile. |
|
| ⌨️ Keyboard Controls | Nudge the crop box with Arrow Keys (10px steps) or fine-tune with Shift + Arrow Keys (1px steps). | |
| 🔧 Quick Tools & Context Menu | Instantly center, toggle grid, or reset via the sidebar or right-click context menu. | |
| System | ⚙️ Zero Dependencies | Runs entirely on Python’s standard library—no additional installations required. |
| 🔌 Smart Port Detection | Automatically selects an available port if the default (8000) is occupied. | |
| 🔄 Rotation Metadata Handling | Automatically detects video rotation (e.g., from mobile phones) using ffprobe and displays dimensions correctly. |
|
| 💻 Advanced Cross-Platform | Fully compatible with Windows, macOS, and Linux, including explicit auto-open support for Termux and WSL environments. | |
| 🛡️ Robust CLI | Powered by argparse for standardized, reliable command-line help (-h) and version (--version) flags. |
🖼️ Screenshots
A modern interface available in both light and dark themes, optimized for every device.
🧠 Supported Preview Formats
MediaCrop computes coordinates for any file readable by FFmpeg, with native in-browser previews for:
- Images: JPG, PNG, WEBP, AVIF, GIF, BMP, SVG, ICO, HEIC, TIFF, JXL
- Videos: MP4, WEBM, MOV, OGV
- Audio: MP3, WAV, FLAC, OGG, M4A, AAC, OPUS
⚙️ Installation
Requires Python 3.7+ and FFmpeg (with ffprobe) installed and available in your system's PATH.
Option 1: Install from PyPI (Recommended)
pip install mediacrop
Option 2: Install from Source
# Clone the repository
git clone https://github.com/mallikmusaddiq1/mediacrop.git
# Navigate into the project directory
cd mediacrop
# Install the package locally
pip install .
🚀 Usage
Run the command below in your terminal:
mediacrop "/path/to/your/mediafile.mp4"
Note: Always enclose file paths containing spaces in quotes.
- The tool automatically launches in your default browser at
http://127.0.0.1:8000.- Adjust the crop box visually, apply aspect ratios, or type exact coordinates into the sidebar.
- Click 💾 Save Coordinates to confirm.
- The FFmpeg crop filter string (e.g.,
crop=...) appears in your terminal.- Press
Ctrl + Cin the terminal to stop the server.
🕹️ Command-Line Options
| Option | Alias | Description |
|---|---|---|
media_file |
Path to the video or image file. (Required) | |
--port <port> |
-p <port> |
Specify a custom server port (default: 8000). |
--host <host> |
Specify a host address (default: 127.0.0.1). | |
--verbose |
-v |
Enable detailed logs for debugging. |
--secure |
-s |
Protect the server with a one-time security token. |
--version |
Show program's version number and exit. | |
--help |
-h |
Show this help message and exit. |
🎬 Using the Output with FFmpeg
MediaCrop produces a command-line-ready crop filter string, such as:
crop=1280:720:320:180
Apply it directly in your FFmpeg command:
ffmpeg -i input.mp4 -vf "crop=1280:720:320:180" output_cropped.mp4
⌨️ Controls & Shortcuts
| Action | Control |
|---|---|
| Move Crop Box | Click + Drag / Arrow Keys |
| Fine Move (1px) | Shift + Arrow Keys |
| Resize Crop Box | Drag Edges/Corners / Pinch (Touch) |
| Set Coordinates Manually | Type in sidebar inputs / Click & Drag on X,Y,W,H labels |
| Zoom Media View | Mouse Wheel / Pinch (Touch) / Double-Tap (Touch) |
| Pan Media View (when zoomed) | Alt + Drag / Middle-Mouse Drag / One-Finger Drag (Touch) |
| Resize Preview Window | Drag 8 handles on preview / Pinch (Touch) on preview |
| Fullscreen Preview | Long-Press on Live Preview Window |
| Toggle Grid | G Key |
| Center Crop Box | C Key |
| Save Coordinates | Enter Key |
| Toggle Help Panel | ? Key / Esc to Close |
| Access Quick Tools | Right-Click on Crop Box |
🤝 Contributing
Contributions are warmly welcomed! Whether you fix bugs, add features, or improve documentation—your input helps make MediaCrop even better.
How to Contribute
- Fork this repository.
- Create a new branch for your update:
git checkout -b feature/your-feature-name
- Commit your changes with a clear, descriptive message.
- Open a Pull Request.
If you find this project valuable, please star ⭐ it on GitHub to support future development!
👨💻 Author
Name: Mallik Mohammad Musaddiq
Email: mallikmusaddiq1@gmail.com
GitHub: mallikmusaddiq1
Project Repo: mallikmusaddiq1/mediacrop
Instagram: @musaddiq.x7
📄 License
This project is licensed under the MIT License. See the LICENSE file for full details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mediacrop-5.4.0.tar.gz.
File metadata
- Download URL: mediacrop-5.4.0.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd813119d068c7979f6955ba9c0f9e1ac366e641d4aad82683d226b1a30cb85a
|
|
| MD5 |
cc7e94f9305451822661f4b511d2493f
|
|
| BLAKE2b-256 |
35843691ff5fac26db037369b738bcf64090ace6dc6bb50fd1018aef514cd05b
|
File details
Details for the file mediacrop-5.4.0-py3-none-any.whl.
File metadata
- Download URL: mediacrop-5.4.0-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc48dc84e0d287b51714bfbd6e202fb4aa3999f68e16f6dd0142de8d1fed5adb
|
|
| MD5 |
9c68a0949cfaa121086077bfffc8bf06
|
|
| BLAKE2b-256 |
0673d07010f18919c912e6d743051faedbbbbfafbb58d59b983b977d240a6ff7
|