Run ffmpeg commands with nicely parsed output.
Project description
FFmpeg output parser
Overview
Do you already know the ffmpeg command line, and don't want to relearn some syntax of a pythonic ffmpeg wrapper? This is the package for you. Just put in an ffmpeg command and this package structures the output while it's processing.
Usage
The code below converts a video, and prints the percentage completion while it's working.
from parsed_ffmpeg import run_ffmpeg, FfmpegError
async def process_video():
try:
await run_ffmpeg(
f"ffmpeg -i input.mp4 -c:v libx264 output.mp4",
on_status=lambda status: print(f"We're: {status.completion * 100:.1f}% there!"),
overwrite_output=True
)
print("Done!")
except FfmpegError as e:
print(f"ffmpeg failed with error: {e}")
Example script output
We're: 8.2% there!
We're: 45.5% there!
We're: 100.0% there!
Done!
Error example
ffmpeg failed with error:
User command:
ffmpeg -i input.mp4 -c:v libx264 output.mp4
Full command:
ffmpeg -i input.mp4 -c:v libx264 output.mp4 -y -progress pipe:1
Working directory:
C:\Users\rutenl\PycharmProjects\parsed_ffmpeg
[in#0 @ 00000208d2d4e1c0] Error opening input: No such file or directory
Error opening input file input.mp4.
Error opening input files: No such file or directory
API
async def run_ffmpeg(
command: list[str] | str,
on_status: Callable[[StatusUpdate], None] | None = None,
on_stdout: Callable[[str], None] | None = None,
on_stderr: Callable[[str], None] | None = None,
on_error: Callable[[list[str]], None] | None = None,
on_warning: Callable[[str], None] | None = None,
overwrite_output: bool = False,
raise_on_error: bool = True,
) -> None:
...
Changing ffmpeg install location
Just replace the first part of your command (ffmpeg) with the path to ffmpeg. Example:
await run_ffmpeg("C:/apps/ffmpeg.exe -i input.mp4 -c:v libx264 output.mp4 -y")
License
MIT
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
parsed_ffmpeg-0.1.0.tar.gz
(3.3 kB
view details)
Built Distribution
File details
Details for the file parsed_ffmpeg-0.1.0.tar.gz
.
File metadata
- Download URL: parsed_ffmpeg-0.1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80c2bea6809076fc4acde4898972a289d09b78c542d123e745fdf8bbd9cd667d |
|
MD5 | f2e53f93df6ef067b487d195db66ef89 |
|
BLAKE2b-256 | 120565f801f7e103b76fe140c3aedf02ae01fee66631262da282e2c1d32204a4 |
File details
Details for the file parsed_ffmpeg-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: parsed_ffmpeg-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c87a69a8d0de5b414c960101f3bd9146d26e6f46d5f98cc12d17d838a31acdd5 |
|
MD5 | b7863a8d691e5724971c4afa7107dfd8 |
|
BLAKE2b-256 | eebdc73c3f47784be668c9501fc74bbb9b55a7804a2faaa6d553b1c7eb3d33f4 |