Skip to main content

Run an ffmpeg command with progress

Project description

ffmpeg-progress-yield

PyPI version

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:

  1. The progress cannot be extracted for sources that don't have a duration (e.g. live sources).

  2. Currently, we do not differentiate between stderr and stdout. This means progress will be mixed with the ffmpeg log.

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

(unreleased)

  • Rename project.

  • Initial commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ffmpeg-progress-yield-0.0.1.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ffmpeg_progress_yield-0.0.1-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ffmpeg-progress-yield-0.0.1.tar.gz.

File metadata

  • Download URL: ffmpeg-progress-yield-0.0.1.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.1

File hashes

Hashes for ffmpeg-progress-yield-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5562af0cb77c6fb7fb1e562d2db58fa8bcc77ef87e2fdd5e824bffd3ee21099e
MD5 7ffb60ffe0c6aff218a5c1c0778decf5
BLAKE2b-256 3a6c970af8ebd4499885660274c07bef027b8e8c3d94d3a65e21fa4b3fcf456a

See more details on using hashes here.

File details

Details for the file ffmpeg_progress_yield-0.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: ffmpeg_progress_yield-0.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.1

File hashes

Hashes for ffmpeg_progress_yield-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 493af7c1d34b709c4f3013f1aaf508d17077cc9f64112acd98271dcf14db9998
MD5 c5ab520fe7c9bf360171ad3d3fb874b9
BLAKE2b-256 a4344d7eebb29965dde060a99854418acc6b16f250d9045057f8b35000099fb3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page