<div align="center">
[![PyPI downloads](https://img.shields.io/pypi/dm/better-ffmpeg-progress?label=PyPI&color=blue)](https://pypistats.org/packages/pypistats)
[![PyPI downloads](https://img.shields.io/pypi/dw/better-ffmpeg-progress?label=PyPI&color=blue)](https://pypistats.org/packages/pypistats)
[![GitHub](https://img.shields.io/github/license/crypticsignal/better-ffmpeg-progress?label=License&color=blue)](LICENSE.txt)
# Better FFmpeg Progress
Runs an FFmpeg command and uses [tqdm](https://github.com/tqdm/tqdm) to show a progress bar.
</div>
## Example:
```
39%|███████████████████████████████████████████ | 23.6/60.2 [00:19<00:34, 1.07s/s]
```
Where:
- `39%` is the percentage progress.
- `23.6` seconds of the input file have been processed.
- `60.2` is the duration of the input file in seconds.
- `00:19` is the time elapsed since the FFmpeg process started.
- `00:34` is the estimated time required for the FFmpeg process to complete.
- `1.07` shows how many seconds of the input file are processed per second.
## Installation:
`pip3 install better-ffmpeg-progress --upgrade`
## Usage:
Create an instance of the `FfmpegProcess` class and supply a list of arguments like you would to `subprocess.run()`.
Simple Example:
```py
from better_ffmpeg_progress import FfmpegProcess
# Pass a list of FFmpeg arguments, like you would if using subprocess.run()
process = FfmpegProcess(["ffmpeg", "-i", "input.mp4", "-c:a", "libmp3lame", "output.mp3"])
# Use the run method to run the FFmpeg command.
process.run()
```
Advanced Example:
```py
from better_ffmpeg_progress import FfmpegProcess
def handle_progress_info(percentage, speed, eta, estimated_filesize):
print(f"Estimated Output Filesize: {estimated_filesize / 1_000_000} MB")
def handle_success():
# Code to run if the FFmpeg process completes successfully.
pass
def handle_error():
# Code to run if the FFmpeg process encounters an error.
pass
# Pass a list of FFmpeg arguments, like you would if using subprocess.run()
process = FfmpegProcess(["ffmpeg", "-i", "input.mp4", "-c:a", "libmp3lame", "output.mp3"])
ffmpeg_output_path = 'ffmpeg_output.txt'
# Use the run method to run the FFmpeg command.
process.run(progress_handler=handle_progress_info, ffmpeg_output_file=ffmpeg_output_path, success_handler=handle_success, error_handler=handle_error)
```
The `run` method takes the following **optional** arguments:
- `progress_handler`
- You can create a function if you would like to do something with the following values:
- Percentage progress. [float]
- Speed, e.g. `22.3x` which means that 22.3 seconds of the input are processed every second. [string]
- ETA in seconds. [float]
- Estimated output filesize in bytes. [float]
- _Note: This is not accurate. Please take the value with a grain of salt._
The values will be `None` if unknown. The function will receive the aforementioned metrics as arguments, about two times per second.
- `ffmpeg_output_file` - A string path to define where you want the output of FFmpeg to be saved. By default, this is saved in a folder named "ffmpeg_output", with the filename `[<input_filename>].txt`.
- `success_handler` - A function to run if the FFmpeg process completes successfully.
- `error_handler` - A function to run if the FFmpeg process encounters an error.
## Changelog:
[19/09/2022]
- Add the ability to specify a `success_handler` argument, a function to run if the FFmpeg process completes successfully.
- Add 0.001 to tqdm's `total` parameter to prevent the chance of getting `TqdmWarning: clamping frac to range [0, 1]`
[21/12/2022]
- [v2.0.7] Fix `'estimated_size' referenced before assignment` error.
- [v2.0.7] The progress bar now uses 1 decimal place for seconds processed and total duration.
[22/12/2022]
- [v2.0.8] Add the ability to specify an `error_handler` argument, a function to run if the FFmpeg process encounters an error.
- [v2.0.9] Fix a typo (commit [da45a84](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/da45a8416856ab7d3c7b748db5703fa3dbc65f60))
[07/02/2022]
- [v2.1.0] [Update function name](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/572fe8a0d71957d00b833134a4d35170630203fa) to fix `'process_complete_handler' is not defined` error.
[05/11/2023]
- [v2.1.2] [Do not exit the Python interpreter after the FFmpeg process is complete](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/0a358810773835297faae688689c6e0d8a5859ae)
[22/04/2024]
- [v2.1.3] Fix issue [#20](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/20)
[28/04/2024]
- [v2.1.4] Fix issue [#21](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/21)
Raw data
{
"_id": null,
"home_page": "https://github.com/CrypticSignal/better-ffmpeg-progress",
"name": "better-ffmpeg-progress",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "ffmpeg, progress",
"author": "GitHub.com/CrypticSignal",
"author_email": "theaudiophile@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/c1/9f/c27d85f4ce6424f13931205092c96d437aa3922ecdaf72459e65a988de08/better-ffmpeg-progress-2.1.5.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n\n[![PyPI downloads](https://img.shields.io/pypi/dm/better-ffmpeg-progress?label=PyPI&color=blue)](https://pypistats.org/packages/pypistats)\n[![PyPI downloads](https://img.shields.io/pypi/dw/better-ffmpeg-progress?label=PyPI&color=blue)](https://pypistats.org/packages/pypistats)\n[![GitHub](https://img.shields.io/github/license/crypticsignal/better-ffmpeg-progress?label=License&color=blue)](LICENSE.txt)\n\n# Better FFmpeg Progress\n\nRuns an FFmpeg command and uses [tqdm](https://github.com/tqdm/tqdm) to show a progress bar.\n\n</div>\n\n## Example:\n\n```\n39%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 | 23.6/60.2 [00:19<00:34, 1.07s/s]\n```\n\nWhere:\n\n- `39%` is the percentage progress.\n- `23.6` seconds of the input file have been processed.\n- `60.2` is the duration of the input file in seconds.\n- `00:19` is the time elapsed since the FFmpeg process started.\n- `00:34` is the estimated time required for the FFmpeg process to complete.\n- `1.07` shows how many seconds of the input file are processed per second.\n\n## Installation:\n\n`pip3 install better-ffmpeg-progress --upgrade`\n\n## Usage:\n\nCreate an instance of the `FfmpegProcess` class and supply a list of arguments like you would to `subprocess.run()`.\n\nSimple Example:\n\n```py\nfrom better_ffmpeg_progress import FfmpegProcess\n# Pass a list of FFmpeg arguments, like you would if using subprocess.run()\nprocess = FfmpegProcess([\"ffmpeg\", \"-i\", \"input.mp4\", \"-c:a\", \"libmp3lame\", \"output.mp3\"])\n# Use the run method to run the FFmpeg command.\nprocess.run()\n```\n\nAdvanced Example:\n\n```py\nfrom better_ffmpeg_progress import FfmpegProcess\n\ndef handle_progress_info(percentage, speed, eta, estimated_filesize):\n print(f\"Estimated Output Filesize: {estimated_filesize / 1_000_000} MB\")\n\ndef handle_success():\n # Code to run if the FFmpeg process completes successfully.\n pass\n\ndef handle_error():\n # Code to run if the FFmpeg process encounters an error.\n pass\n\n# Pass a list of FFmpeg arguments, like you would if using subprocess.run()\nprocess = FfmpegProcess([\"ffmpeg\", \"-i\", \"input.mp4\", \"-c:a\", \"libmp3lame\", \"output.mp3\"])\n\nffmpeg_output_path = 'ffmpeg_output.txt'\n\n# Use the run method to run the FFmpeg command.\nprocess.run(progress_handler=handle_progress_info, ffmpeg_output_file=ffmpeg_output_path, success_handler=handle_success, error_handler=handle_error)\n```\n\nThe `run` method takes the following **optional** arguments:\n\n- `progress_handler`\n\n - You can create a function if you would like to do something with the following values:\n\n - Percentage progress. [float]\n - Speed, e.g. `22.3x` which means that 22.3 seconds of the input are processed every second. [string]\n - ETA in seconds. [float]\n - Estimated output filesize in bytes. [float]\n - _Note: This is not accurate. Please take the value with a grain of salt._\n\n The values will be `None` if unknown. The function will receive the aforementioned metrics as arguments, about two times per second.\n\n- `ffmpeg_output_file` - A string path to define where you want the output of FFmpeg to be saved. By default, this is saved in a folder named \"ffmpeg_output\", with the filename `[<input_filename>].txt`.\n\n- `success_handler` - A function to run if the FFmpeg process completes successfully.\n\n- `error_handler` - A function to run if the FFmpeg process encounters an error.\n\n## Changelog:\n\n[19/09/2022]\n\n- Add the ability to specify a `success_handler` argument, a function to run if the FFmpeg process completes successfully.\n- Add 0.001 to tqdm's `total` parameter to prevent the chance of getting `TqdmWarning: clamping frac to range [0, 1]`\n\n[21/12/2022]\n\n- [v2.0.7] Fix `'estimated_size' referenced before assignment` error.\n- [v2.0.7] The progress bar now uses 1 decimal place for seconds processed and total duration.\n\n[22/12/2022]\n\n- [v2.0.8] Add the ability to specify an `error_handler` argument, a function to run if the FFmpeg process encounters an error.\n- [v2.0.9] Fix a typo (commit [da45a84](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/da45a8416856ab7d3c7b748db5703fa3dbc65f60))\n\n[07/02/2022]\n\n- [v2.1.0] [Update function name](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/572fe8a0d71957d00b833134a4d35170630203fa) to fix `'process_complete_handler' is not defined` error.\n\n[05/11/2023]\n\n- [v2.1.2] [Do not exit the Python interpreter after the FFmpeg process is complete](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/0a358810773835297faae688689c6e0d8a5859ae)\n\n[22/04/2024]\n\n- [v2.1.3] Fix issue [#20](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/20)\n\n[28/04/2024]\n\n- [v2.1.4] Fix issue [#21](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/21)\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Run FFmpeg & see percentage progress + ETA.",
"version": "2.1.5",
"project_urls": {
"Homepage": "https://github.com/CrypticSignal/better-ffmpeg-progress"
},
"split_keywords": [
"ffmpeg",
" progress"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8d18c34df6947047b15c3b4ac555c3178ccf6f7e7ae4ee9cf20720db326e37f5",
"md5": "f510c9f5db00bbac1a0fb57359bd5bb6",
"sha256": "e7ad75242cc23ce14abdcfc1442192d1c139d1a0f3e196eb5bdb05cc4dee8871"
},
"downloads": -1,
"filename": "better_ffmpeg_progress-2.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f510c9f5db00bbac1a0fb57359bd5bb6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5316,
"upload_time": "2024-05-02T18:40:31",
"upload_time_iso_8601": "2024-05-02T18:40:31.048825Z",
"url": "https://files.pythonhosted.org/packages/8d/18/c34df6947047b15c3b4ac555c3178ccf6f7e7ae4ee9cf20720db326e37f5/better_ffmpeg_progress-2.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c19fc27d85f4ce6424f13931205092c96d437aa3922ecdaf72459e65a988de08",
"md5": "ec10e5699252398d1a681ce4dc03d485",
"sha256": "0ef9da5877df4814c397ba5e84e71bfa37eeb1bb581261967e90d70dea45fb27"
},
"downloads": -1,
"filename": "better-ffmpeg-progress-2.1.5.tar.gz",
"has_sig": false,
"md5_digest": "ec10e5699252398d1a681ce4dc03d485",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5660,
"upload_time": "2024-05-02T18:40:34",
"upload_time_iso_8601": "2024-05-02T18:40:34.684000Z",
"url": "https://files.pythonhosted.org/packages/c1/9f/c27d85f4ce6424f13931205092c96d437aa3922ecdaf72459e65a988de08/better-ffmpeg-progress-2.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-02 18:40:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "CrypticSignal",
"github_project": "better-ffmpeg-progress",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "better-ffmpeg-progress"
}