Run an ffmpeg command with progress
Project description
ffmpeg-progress-yield
Run an ffmpeg command with its progress yielded.
Contents:
Requirements
- Python 3.6 or higher
- ffmpeg v3.1 or above from http://ffmpeg.org/ installed in your $PATH
Installation
pip3 install ffmpeg-progress-yield
Or download this repository, then run pip install .
.
Usage
In your Python project, import the helper class and run run_command_with_progress
:
from ffmpeg_progress_yield import FfmpegProgress
cmd = [
"ffmpeg", "-i", "test/test.mp4", "-c:v", "libx264", "-vf", "scale=1920x1080", "-preset", "fast", "-f", "null", "/dev/null",
]
ff = FfmpegProgress(cmd)
for progress in ff.run_command_with_progress():
print(f"{progress}/100")
The command will yield the current progress in percent.
If you have tqdm
installed, you can create a fancy progress bar:
from tqdm import tqdm
from ffmpeg_progress_yield import FfmpegProgress
cmd = [
"ffmpeg", "-i", "test/test.mp4", "-c:v", "libx264", "-vf", "scale=1920x1080", "-preset", "fast", "-f", "null", "/dev/null",
]
ff = FfmpegProgress(cmd)
with tqdm(total=100, position=1, desc="Test") as pbar:
for progress in ff.run_command_with_progress():
pbar.update(progress - pbar.n)
You can get the output of the command with the .stderr
attribute of the FfmpegProgress
class.
Caveats
Some notes:
-
The progress cannot be extracted for sources that don't have a duration (e.g. live sources).
-
Currently, we do not differentiate between
stderr
andstdout
. This means progress will be mixed with the ffmpeg log.
You can also check out ffmpeg-progress
for a similar project with a different feature set.
License
The MIT License (MIT)
Copyright (c) 2021 Werner Robitza
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Changelog
v0.1.2 (2021-08-14)
- Remove universal_newlines for Windows compat.
v0.1.1 (2021-07-01)
- Remove stats_period option for backwards compatibility, fixes #2.
v0.1.0 (2021-06-30)
-
Format code with black.
-
Yield 0 in progress and improve logic.
-
Set universal_newlines to true and add kwargs support.
-
Increase stats period.
-
Document method.
-
Add typing.
-
Also check for 0 in output.
-
Update gitignore.
-
Drop python 3.5 support.
-
Update badge link.
v0.0.4 (2021-03-10)
- Add python_requires to setup.py.
v0.0.3 (2021-03-06)
- Remove release script.
v0.0.2 (2021-03-06)
-
Fix release script.
-
Remove support for older versions.
-
Format setup.py.
-
Remove requirement for command to start with ffmpeg.
-
Add link to similar project.
-
Add changelog.
-
Rename project.
-
Initial commit.
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
Hashes for ffmpeg-progress-yield-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92ae36ff5cf38428bd3695629b5065d161c658fb0de0faf2c20cd7a99dac3820 |
|
MD5 | fce94d08781c705d8afdc4c94edc0697 |
|
BLAKE2b-256 | fe304d0f089c761e6e14652da2421e3613af4e9b3aa83f74a02f51b0b3c816c5 |
Hashes for ffmpeg_progress_yield-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bab568aeaa2c6069da502640e735ddb58e746fd9778e617a3a750b37d0ebcd2d |
|
MD5 | d386b55bd34879440ddda5fa94a090da |
|
BLAKE2b-256 | 016f7b86d5f1fab2b95c8ea471caa614fe39d606b6fffd01d6232b90a777d3f1 |