ffmpeg-studio provides a Pythonic interface to FFmpeg, allowing users to construct and execute FFmpeg commands programmatically.
It simplifies and Handles:
- Complex filter generation
- All popular Filters and Baseclass for custom filters
- Safe quoting & escaping
- Input handling & stream selection
- Output mapping & stream selection
- Progress tracking with callbacks
- Allows direct flags in command.
- Scanning metadata with ffprobe.
- Long filter graphs.
From PyPi
pip install ffmpeg-studio
From Source
pip install git+https://github.com/electro199/ffmpeg-studio.git
ffmpeg-studio support complex Filters and can be used with apply
or apply2
.
from ffmpeg import FFmpeg, InputFile, FileInputOptions, Map
from ffmpeg.filters import apply, Scale, Overlay
# set options
clip = InputFile("video.mp4", FileInputOptions(duration=10))
overlay = InputFile("overlay.png")
# apply scale filter on clip
upscaled_clip = apply(Scale(1440, 1920), clip)
# apply scale filter on overlay
overlay = apply(Scale(100, 100), overlay)
# apply overlay filter with overlay on upscaled_clip
upscaled_clip = apply(Overlay(overlay, x=0, y=10), clip)
# run command
ffmpeg = (
FFmpeg().output(upscaled_clip, path="out.mp4").run(progress_callback=print)
)
For simple media conversion :
from ffmpeg.inputs import VideoFile
from ffmpeg import export
clip = VideoFile("video.mp4")
export(
clip,
path="out.mkv",
).run()
This project does not install ffmpeg utility automatically.
Verify ffmpeg is installed:
ffmpeg -version
Using winget:
winget install --id=Gyan.FFmpeg -e
or download and install FFmpeg from FFmpeg official website:
- Download the latest FFmpeg build from here.
- Extract the archive and add the
bin
directory to your systemPATH
.
Using Homebrew:
brew install ffmpeg
For Debian/Ubuntu:
sudo apt install ffmpeg
-
All Input methods
- Generic(Input) class
- ImageFile class
- VideoFile class
- AudioFile class
- VituralVideo class
- VituralAudio class
-
Output options
- Muliple output per command
- filter_file for super long filters
- Per map flags
- Per output flags
-
Improve progress tracking
- Support callbacks with frame/time info
- Provide async interface for streaming progress
-
Documentation & Examples
- Basic tutorials.
- Showcase filtergraph construction with helpers
- Detailed tutorials.
- Detailed example/gallery.
-
Testing & CI
- Publish to PyPI every release
- Publish Docs every release
- Verify cross-platform behavior (Linux/Windows/macOS)
- GitHub Actions for automated testing
-
Packaging & Distribution
- Publish to PyPI