better-ffmpeg-progress 2.5.8__tar.gz → 2.6.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/PKG-INFO +3 -74
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/README.md +3 -74
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/better_ffmpeg_progress/better_ffmpeg_progress.py +61 -33
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/better_ffmpeg_progress/utils.py +1 -1
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/better_ffmpeg_progress.egg-info/PKG-INFO +3 -74
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/setup.py +1 -1
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/LICENSE +0 -0
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/better_ffmpeg_progress/__init__.py +0 -0
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/better_ffmpeg_progress.egg-info/SOURCES.txt +0 -0
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/better_ffmpeg_progress.egg-info/dependency_links.txt +0 -0
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/better_ffmpeg_progress.egg-info/requires.txt +0 -0
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/better_ffmpeg_progress.egg-info/top_level.txt +0 -0
- {better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: better-ffmpeg-progress
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.6.1
|
|
4
4
|
Summary: Run FFmpeg & see percentage progress + ETA.
|
|
5
5
|
Home-page: https://github.com/CrypticSignal/better-ffmpeg-progress
|
|
6
6
|
Author: GitHub.com/CrypticSignal
|
|
@@ -91,11 +91,12 @@ process.run(
|
|
|
91
91
|
## Optional Arguments
|
|
92
92
|
An instance of the `FfmpegProcess` class takes the following **optional** arguments:
|
|
93
93
|
|
|
94
|
-
- `ffmpeg_loglevel`: Desired FFmpeg log level. Default: "verbose"
|
|
94
|
+
- `ffmpeg_loglevel`: Desired FFmpeg log level. Default: `"verbose"`
|
|
95
95
|
- `print_stderr_new_line`: If better progress information cannot be shown, print FFmpeg stderr in a new line instead of replacing the current line in the terminal. Default: False
|
|
96
96
|
- `print_detected_duration`: Print the detected duration of the input file. Default: True
|
|
97
97
|
|
|
98
98
|
The `run` method takes the following **optional** arguments:
|
|
99
|
+
- `print_command` - Print the FFmpeg command being executed. Default: `False`
|
|
99
100
|
- `progress_bar_description` - An optional string to set a custom description for the progress bar. The default description is `Processing <file>`. This can be an empty string if you don't want the progress bar to have a description.
|
|
100
101
|
- `progress_handler`
|
|
101
102
|
- You can create a function if you would like to do something with the following values:
|
|
@@ -110,75 +111,3 @@ The `run` method takes the following **optional** arguments:
|
|
|
110
111
|
- `log_file` - The filepath to save the FFmpeg log to.
|
|
111
112
|
- `success_handler` - A function to run if the FFmpeg process completes successfully.
|
|
112
113
|
- `error_handler` - A function to run if the FFmpeg process encounters an error.
|
|
113
|
-
|
|
114
|
-
## Changelog
|
|
115
|
-
[19/09/2022]
|
|
116
|
-
- Add the ability to specify a `success_handler` argument, a function to run if the FFmpeg process completes successfully.
|
|
117
|
-
- Add 0.001 to tqdm's `total` parameter to prevent the chance of getting `TqdmWarning: clamping frac to range [0, 1]`
|
|
118
|
-
|
|
119
|
-
[21/12/2022]
|
|
120
|
-
- [v2.0.7] Fix `'estimated_size' referenced before assignment` error.
|
|
121
|
-
- [v2.0.7] The progress bar now uses 1 decimal place for seconds processed and total duration.
|
|
122
|
-
|
|
123
|
-
[22/12/2022]
|
|
124
|
-
- [v2.0.8] Add the ability to specify an `error_handler` argument, a function to run if the FFmpeg process encounters an error.
|
|
125
|
-
- [v2.0.9] Fix a typo (commit [da45a84](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/da45a8416856ab7d3c7b748db5703fa3dbc65f60))
|
|
126
|
-
|
|
127
|
-
[07/02/2022]
|
|
128
|
-
- [v2.1.0] [Update function name](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/572fe8a0d71957d00b833134a4d35170630203fa) to fix `'process_complete_handler' is not defined` error.
|
|
129
|
-
|
|
130
|
-
[05/11/2023]
|
|
131
|
-
- [v2.1.2] [Do not exit the Python interpreter after the FFmpeg process is complete](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/0a358810773835297faae688689c6e0d8a5859ae)
|
|
132
|
-
|
|
133
|
-
[22/04/2024]
|
|
134
|
-
- [v2.1.3] Fix issue [#20](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/20)
|
|
135
|
-
|
|
136
|
-
[28/04/2024]
|
|
137
|
-
- [v2.1.4] Fix issue [#21](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/21)
|
|
138
|
-
|
|
139
|
-
[02/05/2024]
|
|
140
|
-
- [v2.1.5] Fix issue [#23](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/23) and make an error message more specific. [Here](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/a6ef7f26d080b684144021301f3b2aa5e0834dae) is the relevant commit.
|
|
141
|
-
|
|
142
|
-
[18/10/2024]
|
|
143
|
-
- [v2.1.6] Notify the user if the input filepath or filename is incorrect.
|
|
144
|
-
- [v2.1.7] Refactor to use threads and queues.
|
|
145
|
-
|
|
146
|
-
[19/10/2024]
|
|
147
|
-
- [v2.1.8] Use [Rich](https://github.com/Textualize/rich) instead of [tqdm](https://github.com/tqdm/tqdm) and format code with [Ruff](https://github.com/astral-sh/ruff).
|
|
148
|
-
|
|
149
|
-
[20/10/2024]
|
|
150
|
-
- [v2.1.9] Do not clear the terminal before showing the progress bar.
|
|
151
|
-
- [v2.2.0] Add the ability to set a custom description for the progress bar.
|
|
152
|
-
|
|
153
|
-
[22/10/2024]
|
|
154
|
-
- [v2.2.1] Only create a log file if the `log_file` parameter is specified and always create a log file if the FFmpeg process fails.
|
|
155
|
-
|
|
156
|
-
[28/10/2024]
|
|
157
|
-
- [v2.2.2] Make printing the detected duration of the input file optional.
|
|
158
|
-
|
|
159
|
-
[29/10/2024]
|
|
160
|
-
- [v2.3.0] Set `shell=True` to support piping.
|
|
161
|
-
- [v2.3.1] Kill FFmpeg process(es) on KeyboardInterrupt
|
|
162
|
-
|
|
163
|
-
[31/10/2024]
|
|
164
|
-
- [v2.4.0] Print FFmpeg stderr if better progress information cannot be shown.
|
|
165
|
-
- [v2.4.0] Flush the stream when printing FFmpeg stderr to ensure that it is printed immediately.
|
|
166
|
-
- [v2.5.0] Add an option to print FFmpeg stderr on a new line if better progress information cannot be shown.
|
|
167
|
-
|
|
168
|
-
[11/11/2024]
|
|
169
|
-
- [v2.5.1] Print the correct log file.
|
|
170
|
-
|
|
171
|
-
[12/11/2024]
|
|
172
|
-
- [v2.5.2] Drain any remaining FFmpeg stderr after the process ends.
|
|
173
|
-
- [v2.5.3] Write FFmpeg stderr to the log file in real time.
|
|
174
|
-
- [v2.5.4] Include progress info in stderr if the duration of the input file cannot be detected.
|
|
175
|
-
- [v2.5.5] Print detected errors in the terminal and only set `shell=True` if shell operators are detected.
|
|
176
|
-
|
|
177
|
-
[13/11/2024]
|
|
178
|
-
- [v2.5.6] Detect a wider range of errors.
|
|
179
|
-
|
|
180
|
-
[18/11/2024]
|
|
181
|
-
- [v2.5.7] Fix syntax. Should fix issue #26
|
|
182
|
-
|
|
183
|
-
[19/11/2024]
|
|
184
|
-
- [v2.5.8] Remove `\n` from replacement fields in f-strings. Should fix issue #26
|
|
@@ -73,11 +73,12 @@ process.run(
|
|
|
73
73
|
## Optional Arguments
|
|
74
74
|
An instance of the `FfmpegProcess` class takes the following **optional** arguments:
|
|
75
75
|
|
|
76
|
-
- `ffmpeg_loglevel`: Desired FFmpeg log level. Default: "verbose"
|
|
76
|
+
- `ffmpeg_loglevel`: Desired FFmpeg log level. Default: `"verbose"`
|
|
77
77
|
- `print_stderr_new_line`: If better progress information cannot be shown, print FFmpeg stderr in a new line instead of replacing the current line in the terminal. Default: False
|
|
78
78
|
- `print_detected_duration`: Print the detected duration of the input file. Default: True
|
|
79
79
|
|
|
80
80
|
The `run` method takes the following **optional** arguments:
|
|
81
|
+
- `print_command` - Print the FFmpeg command being executed. Default: `False`
|
|
81
82
|
- `progress_bar_description` - An optional string to set a custom description for the progress bar. The default description is `Processing <file>`. This can be an empty string if you don't want the progress bar to have a description.
|
|
82
83
|
- `progress_handler`
|
|
83
84
|
- You can create a function if you would like to do something with the following values:
|
|
@@ -91,76 +92,4 @@ The `run` method takes the following **optional** arguments:
|
|
|
91
92
|
|
|
92
93
|
- `log_file` - The filepath to save the FFmpeg log to.
|
|
93
94
|
- `success_handler` - A function to run if the FFmpeg process completes successfully.
|
|
94
|
-
- `error_handler` - A function to run if the FFmpeg process encounters an error.
|
|
95
|
-
|
|
96
|
-
## Changelog
|
|
97
|
-
[19/09/2022]
|
|
98
|
-
- Add the ability to specify a `success_handler` argument, a function to run if the FFmpeg process completes successfully.
|
|
99
|
-
- Add 0.001 to tqdm's `total` parameter to prevent the chance of getting `TqdmWarning: clamping frac to range [0, 1]`
|
|
100
|
-
|
|
101
|
-
[21/12/2022]
|
|
102
|
-
- [v2.0.7] Fix `'estimated_size' referenced before assignment` error.
|
|
103
|
-
- [v2.0.7] The progress bar now uses 1 decimal place for seconds processed and total duration.
|
|
104
|
-
|
|
105
|
-
[22/12/2022]
|
|
106
|
-
- [v2.0.8] Add the ability to specify an `error_handler` argument, a function to run if the FFmpeg process encounters an error.
|
|
107
|
-
- [v2.0.9] Fix a typo (commit [da45a84](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/da45a8416856ab7d3c7b748db5703fa3dbc65f60))
|
|
108
|
-
|
|
109
|
-
[07/02/2022]
|
|
110
|
-
- [v2.1.0] [Update function name](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/572fe8a0d71957d00b833134a4d35170630203fa) to fix `'process_complete_handler' is not defined` error.
|
|
111
|
-
|
|
112
|
-
[05/11/2023]
|
|
113
|
-
- [v2.1.2] [Do not exit the Python interpreter after the FFmpeg process is complete](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/0a358810773835297faae688689c6e0d8a5859ae)
|
|
114
|
-
|
|
115
|
-
[22/04/2024]
|
|
116
|
-
- [v2.1.3] Fix issue [#20](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/20)
|
|
117
|
-
|
|
118
|
-
[28/04/2024]
|
|
119
|
-
- [v2.1.4] Fix issue [#21](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/21)
|
|
120
|
-
|
|
121
|
-
[02/05/2024]
|
|
122
|
-
- [v2.1.5] Fix issue [#23](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/23) and make an error message more specific. [Here](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/a6ef7f26d080b684144021301f3b2aa5e0834dae) is the relevant commit.
|
|
123
|
-
|
|
124
|
-
[18/10/2024]
|
|
125
|
-
- [v2.1.6] Notify the user if the input filepath or filename is incorrect.
|
|
126
|
-
- [v2.1.7] Refactor to use threads and queues.
|
|
127
|
-
|
|
128
|
-
[19/10/2024]
|
|
129
|
-
- [v2.1.8] Use [Rich](https://github.com/Textualize/rich) instead of [tqdm](https://github.com/tqdm/tqdm) and format code with [Ruff](https://github.com/astral-sh/ruff).
|
|
130
|
-
|
|
131
|
-
[20/10/2024]
|
|
132
|
-
- [v2.1.9] Do not clear the terminal before showing the progress bar.
|
|
133
|
-
- [v2.2.0] Add the ability to set a custom description for the progress bar.
|
|
134
|
-
|
|
135
|
-
[22/10/2024]
|
|
136
|
-
- [v2.2.1] Only create a log file if the `log_file` parameter is specified and always create a log file if the FFmpeg process fails.
|
|
137
|
-
|
|
138
|
-
[28/10/2024]
|
|
139
|
-
- [v2.2.2] Make printing the detected duration of the input file optional.
|
|
140
|
-
|
|
141
|
-
[29/10/2024]
|
|
142
|
-
- [v2.3.0] Set `shell=True` to support piping.
|
|
143
|
-
- [v2.3.1] Kill FFmpeg process(es) on KeyboardInterrupt
|
|
144
|
-
|
|
145
|
-
[31/10/2024]
|
|
146
|
-
- [v2.4.0] Print FFmpeg stderr if better progress information cannot be shown.
|
|
147
|
-
- [v2.4.0] Flush the stream when printing FFmpeg stderr to ensure that it is printed immediately.
|
|
148
|
-
- [v2.5.0] Add an option to print FFmpeg stderr on a new line if better progress information cannot be shown.
|
|
149
|
-
|
|
150
|
-
[11/11/2024]
|
|
151
|
-
- [v2.5.1] Print the correct log file.
|
|
152
|
-
|
|
153
|
-
[12/11/2024]
|
|
154
|
-
- [v2.5.2] Drain any remaining FFmpeg stderr after the process ends.
|
|
155
|
-
- [v2.5.3] Write FFmpeg stderr to the log file in real time.
|
|
156
|
-
- [v2.5.4] Include progress info in stderr if the duration of the input file cannot be detected.
|
|
157
|
-
- [v2.5.5] Print detected errors in the terminal and only set `shell=True` if shell operators are detected.
|
|
158
|
-
|
|
159
|
-
[13/11/2024]
|
|
160
|
-
- [v2.5.6] Detect a wider range of errors.
|
|
161
|
-
|
|
162
|
-
[18/11/2024]
|
|
163
|
-
- [v2.5.7] Fix syntax. Should fix issue #26
|
|
164
|
-
|
|
165
|
-
[19/11/2024]
|
|
166
|
-
- [v2.5.8] Remove `\n` from replacement fields in f-strings. Should fix issue #26
|
|
95
|
+
- `error_handler` - A function to run if the FFmpeg process encounters an error.
|
|
@@ -7,7 +7,7 @@ import sys
|
|
|
7
7
|
from threading import Thread
|
|
8
8
|
from typing import Callable, List, Optional, Union
|
|
9
9
|
|
|
10
|
-
from .utils import
|
|
10
|
+
from .utils import print_with_prefix
|
|
11
11
|
|
|
12
12
|
from ffmpeg import probe
|
|
13
13
|
import psutil
|
|
@@ -52,7 +52,7 @@ class FfmpegProcess:
|
|
|
52
52
|
self,
|
|
53
53
|
command: List[str],
|
|
54
54
|
ffmpeg_loglevel: str = "verbose",
|
|
55
|
-
print_detected_duration: bool =
|
|
55
|
+
print_detected_duration: bool = False,
|
|
56
56
|
print_stderr_new_line: bool = False,
|
|
57
57
|
):
|
|
58
58
|
if "-i" not in command:
|
|
@@ -60,17 +60,17 @@ class FfmpegProcess:
|
|
|
60
60
|
|
|
61
61
|
# -progress pipe:1 sends progress metrics to stdout
|
|
62
62
|
# -stats_period sets the period at which encoding progress/statistics are updated
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
extra_ffmpeg_options = [
|
|
64
|
+
"-hide_banner",
|
|
65
|
+
"-loglevel",
|
|
66
|
+
ffmpeg_loglevel,
|
|
67
|
+
"-progress",
|
|
68
|
+
"pipe:1",
|
|
69
|
+
"-stats_period",
|
|
70
|
+
"0.1",
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
command[1:1] = extra_ffmpeg_options
|
|
74
74
|
|
|
75
75
|
self._ffmpeg_command = command
|
|
76
76
|
self._output_filepath = Path(command[-1])
|
|
@@ -81,7 +81,6 @@ class FfmpegProcess:
|
|
|
81
81
|
self._current_size: int = 0
|
|
82
82
|
self._ffmpeg_log_file: Optional[Path] = None
|
|
83
83
|
self._error_messages: list[str] = []
|
|
84
|
-
line()
|
|
85
84
|
self._get_input_file_duration()
|
|
86
85
|
|
|
87
86
|
def _get_input_file_duration(self) -> None:
|
|
@@ -95,31 +94,36 @@ class FfmpegProcess:
|
|
|
95
94
|
)
|
|
96
95
|
|
|
97
96
|
if self._print_detected_duration:
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
print_with_prefix(
|
|
98
|
+
"[Better FFmpeg Progress] ",
|
|
99
|
+
f"The duration of {self._input_filepath.name} has been detected as {self._duration_secs} seconds",
|
|
100
100
|
)
|
|
101
101
|
|
|
102
102
|
# -nostats ensures that progress information is not sent to stderr as this info is not needed in the log file, e.g.
|
|
103
103
|
# frame= 1381 fps=254 q=18.0 size= 46592KiB time=00:00:46.07 bitrate=8283.1kbits/s speed=8.47x
|
|
104
104
|
self._ffmpeg_command.extend(["-nostats"])
|
|
105
105
|
except Exception:
|
|
106
|
-
|
|
106
|
+
print_with_prefix(
|
|
107
|
+
"[Better FFmpeg Progress] ",
|
|
107
108
|
f"Could not detect the duration of '{self._input_filepath.name}'. Percentage progress, ETA and estimated filesize will be unavailable.\n",
|
|
108
109
|
)
|
|
109
110
|
self._duration_secs = None
|
|
110
111
|
|
|
111
|
-
def
|
|
112
|
-
"""Check if output file exists and handle overwrite prompt."""
|
|
112
|
+
def _should_overwrite(self) -> bool:
|
|
113
113
|
if self._output_filepath.exists() and "-y" not in self._ffmpeg_command:
|
|
114
114
|
choice = input(
|
|
115
115
|
f"{self._output_filepath} already exists. Overwrite? [Y/N]: "
|
|
116
116
|
).lower()
|
|
117
|
+
|
|
117
118
|
if choice != "y":
|
|
118
|
-
|
|
119
|
-
"FFmpeg
|
|
119
|
+
print_with_prefix(
|
|
120
|
+
"[Better FFmpeg Progress] ",
|
|
121
|
+
"FFmpeg process cancelled. Output file exists and overwrite declined.",
|
|
120
122
|
)
|
|
121
123
|
return False
|
|
124
|
+
|
|
122
125
|
self._ffmpeg_command.insert(1, "-y")
|
|
126
|
+
|
|
123
127
|
return True
|
|
124
128
|
|
|
125
129
|
def _update_metrics(
|
|
@@ -240,6 +244,7 @@ class FfmpegProcess:
|
|
|
240
244
|
if self._duration_secs is not None:
|
|
241
245
|
try:
|
|
242
246
|
stdout = stdout_queue.get_nowait()
|
|
247
|
+
|
|
243
248
|
if stdout:
|
|
244
249
|
metric, value = stdout.split("=")
|
|
245
250
|
if (
|
|
@@ -265,6 +270,7 @@ class FfmpegProcess:
|
|
|
265
270
|
|
|
266
271
|
try:
|
|
267
272
|
stderr = stderr_queue.get_nowait()
|
|
273
|
+
|
|
268
274
|
if stderr:
|
|
269
275
|
self._write_to_log_file(stderr)
|
|
270
276
|
|
|
@@ -282,8 +288,8 @@ class FfmpegProcess:
|
|
|
282
288
|
|
|
283
289
|
except KeyboardInterrupt:
|
|
284
290
|
self._kill_process_and_children(process.pid)
|
|
285
|
-
self._write_to_log_file("\n[KeyboardInterrupt] FFmpeg process
|
|
286
|
-
sys.exit("\n[KeyboardInterrupt] FFmpeg process
|
|
291
|
+
self._write_to_log_file("\n[KeyboardInterrupt] FFmpeg process killed.")
|
|
292
|
+
sys.exit("\n[KeyboardInterrupt] FFmpeg process killed.")
|
|
287
293
|
|
|
288
294
|
# After the process ends, drain any remaining stderr
|
|
289
295
|
while True:
|
|
@@ -309,6 +315,7 @@ class FfmpegProcess:
|
|
|
309
315
|
def run(
|
|
310
316
|
self,
|
|
311
317
|
log_file: Optional[Union[str, Path]] = "ffmpeg_log.txt",
|
|
318
|
+
print_command=False,
|
|
312
319
|
progress_bar_description: str = None,
|
|
313
320
|
progress_handler: Optional[Callable] = None,
|
|
314
321
|
success_handler: Optional[Callable] = None,
|
|
@@ -317,12 +324,13 @@ class FfmpegProcess:
|
|
|
317
324
|
"""
|
|
318
325
|
Args:
|
|
319
326
|
log_file: Optional filepath to write FFmpeg output to
|
|
327
|
+
print_command: Print the FFmpeg command being executed. Default: False
|
|
320
328
|
progress_bar_description: Optional string to set a custom description for the progress bar
|
|
321
329
|
progress_handler: Optional function which receives progress metrics
|
|
322
330
|
success_handler: Optional function to handle successful completion of the FFmpeg process
|
|
323
331
|
error_handler: Optional function for FFmpeg process error handling
|
|
324
332
|
"""
|
|
325
|
-
if not self.
|
|
333
|
+
if not self._should_overwrite():
|
|
326
334
|
return
|
|
327
335
|
|
|
328
336
|
self._ffmpeg_log_file = Path(log_file)
|
|
@@ -330,8 +338,8 @@ class FfmpegProcess:
|
|
|
330
338
|
with open(self._ffmpeg_log_file, "w"):
|
|
331
339
|
pass
|
|
332
340
|
|
|
333
|
-
|
|
334
|
-
|
|
341
|
+
if print_command:
|
|
342
|
+
print(f"Executing: {' '.join(self._ffmpeg_command)}")
|
|
335
343
|
|
|
336
344
|
if self._duration_secs and not progress_handler:
|
|
337
345
|
with Progress(
|
|
@@ -355,6 +363,16 @@ class FfmpegProcess:
|
|
|
355
363
|
task_id,
|
|
356
364
|
None,
|
|
357
365
|
)
|
|
366
|
+
|
|
367
|
+
if return_code == 0:
|
|
368
|
+
progress_bar.columns = (
|
|
369
|
+
TextColumn("[progress.description]{task.description}"),
|
|
370
|
+
)
|
|
371
|
+
progress_bar.update(
|
|
372
|
+
task_id,
|
|
373
|
+
description=f"✓ Processed 100% of {self._input_filepath.name}",
|
|
374
|
+
)
|
|
375
|
+
|
|
358
376
|
else:
|
|
359
377
|
return_code = self._start_process(
|
|
360
378
|
None,
|
|
@@ -362,6 +380,12 @@ class FfmpegProcess:
|
|
|
362
380
|
progress_handler,
|
|
363
381
|
)
|
|
364
382
|
|
|
383
|
+
if return_code == 0:
|
|
384
|
+
print_with_prefix(
|
|
385
|
+
"\n" if self._duration_secs is None else "",
|
|
386
|
+
"FFmpeg process completed.",
|
|
387
|
+
)
|
|
388
|
+
|
|
365
389
|
self._handle_process_ended(return_code, error_handler, success_handler)
|
|
366
390
|
|
|
367
391
|
def _handle_process_ended(
|
|
@@ -378,17 +402,21 @@ class FfmpegProcess:
|
|
|
378
402
|
"\nThe FFmpeg process encounted an error. Custom error handler executed."
|
|
379
403
|
)
|
|
380
404
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
405
|
+
print_with_prefix(
|
|
406
|
+
"[Better FFmpeg Progress] ",
|
|
407
|
+
f"FFmpeg process failed with return code {return_code}.\nError(s):",
|
|
408
|
+
)
|
|
409
|
+
print_with_prefix(
|
|
410
|
+
"[Better FFmpeg Progress] ", "\n".join(self._error_messages)
|
|
411
|
+
)
|
|
412
|
+
print_with_prefix(
|
|
413
|
+
"[Better FFmpeg Progress] ",
|
|
414
|
+
f"Check out '{self._ffmpeg_log_file}' for more details.",
|
|
415
|
+
)
|
|
384
416
|
sys.exit(1)
|
|
385
417
|
|
|
386
418
|
if success_handler:
|
|
387
419
|
success_handler()
|
|
388
|
-
else:
|
|
389
|
-
print_with_prefix(
|
|
390
|
-
"FFmpeg process completed.", "\n" if self._duration_secs is None else ""
|
|
391
|
-
)
|
|
392
420
|
|
|
393
421
|
def _kill_process_and_children(self, proc_pid: int) -> None:
|
|
394
422
|
"""Kill the FFmpeg process and its children."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: better-ffmpeg-progress
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.6.1
|
|
4
4
|
Summary: Run FFmpeg & see percentage progress + ETA.
|
|
5
5
|
Home-page: https://github.com/CrypticSignal/better-ffmpeg-progress
|
|
6
6
|
Author: GitHub.com/CrypticSignal
|
|
@@ -91,11 +91,12 @@ process.run(
|
|
|
91
91
|
## Optional Arguments
|
|
92
92
|
An instance of the `FfmpegProcess` class takes the following **optional** arguments:
|
|
93
93
|
|
|
94
|
-
- `ffmpeg_loglevel`: Desired FFmpeg log level. Default: "verbose"
|
|
94
|
+
- `ffmpeg_loglevel`: Desired FFmpeg log level. Default: `"verbose"`
|
|
95
95
|
- `print_stderr_new_line`: If better progress information cannot be shown, print FFmpeg stderr in a new line instead of replacing the current line in the terminal. Default: False
|
|
96
96
|
- `print_detected_duration`: Print the detected duration of the input file. Default: True
|
|
97
97
|
|
|
98
98
|
The `run` method takes the following **optional** arguments:
|
|
99
|
+
- `print_command` - Print the FFmpeg command being executed. Default: `False`
|
|
99
100
|
- `progress_bar_description` - An optional string to set a custom description for the progress bar. The default description is `Processing <file>`. This can be an empty string if you don't want the progress bar to have a description.
|
|
100
101
|
- `progress_handler`
|
|
101
102
|
- You can create a function if you would like to do something with the following values:
|
|
@@ -110,75 +111,3 @@ The `run` method takes the following **optional** arguments:
|
|
|
110
111
|
- `log_file` - The filepath to save the FFmpeg log to.
|
|
111
112
|
- `success_handler` - A function to run if the FFmpeg process completes successfully.
|
|
112
113
|
- `error_handler` - A function to run if the FFmpeg process encounters an error.
|
|
113
|
-
|
|
114
|
-
## Changelog
|
|
115
|
-
[19/09/2022]
|
|
116
|
-
- Add the ability to specify a `success_handler` argument, a function to run if the FFmpeg process completes successfully.
|
|
117
|
-
- Add 0.001 to tqdm's `total` parameter to prevent the chance of getting `TqdmWarning: clamping frac to range [0, 1]`
|
|
118
|
-
|
|
119
|
-
[21/12/2022]
|
|
120
|
-
- [v2.0.7] Fix `'estimated_size' referenced before assignment` error.
|
|
121
|
-
- [v2.0.7] The progress bar now uses 1 decimal place for seconds processed and total duration.
|
|
122
|
-
|
|
123
|
-
[22/12/2022]
|
|
124
|
-
- [v2.0.8] Add the ability to specify an `error_handler` argument, a function to run if the FFmpeg process encounters an error.
|
|
125
|
-
- [v2.0.9] Fix a typo (commit [da45a84](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/da45a8416856ab7d3c7b748db5703fa3dbc65f60))
|
|
126
|
-
|
|
127
|
-
[07/02/2022]
|
|
128
|
-
- [v2.1.0] [Update function name](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/572fe8a0d71957d00b833134a4d35170630203fa) to fix `'process_complete_handler' is not defined` error.
|
|
129
|
-
|
|
130
|
-
[05/11/2023]
|
|
131
|
-
- [v2.1.2] [Do not exit the Python interpreter after the FFmpeg process is complete](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/0a358810773835297faae688689c6e0d8a5859ae)
|
|
132
|
-
|
|
133
|
-
[22/04/2024]
|
|
134
|
-
- [v2.1.3] Fix issue [#20](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/20)
|
|
135
|
-
|
|
136
|
-
[28/04/2024]
|
|
137
|
-
- [v2.1.4] Fix issue [#21](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/21)
|
|
138
|
-
|
|
139
|
-
[02/05/2024]
|
|
140
|
-
- [v2.1.5] Fix issue [#23](https://github.com/CrypticSignal/better-ffmpeg-progress/issues/23) and make an error message more specific. [Here](https://github.com/CrypticSignal/better-ffmpeg-progress/commit/a6ef7f26d080b684144021301f3b2aa5e0834dae) is the relevant commit.
|
|
141
|
-
|
|
142
|
-
[18/10/2024]
|
|
143
|
-
- [v2.1.6] Notify the user if the input filepath or filename is incorrect.
|
|
144
|
-
- [v2.1.7] Refactor to use threads and queues.
|
|
145
|
-
|
|
146
|
-
[19/10/2024]
|
|
147
|
-
- [v2.1.8] Use [Rich](https://github.com/Textualize/rich) instead of [tqdm](https://github.com/tqdm/tqdm) and format code with [Ruff](https://github.com/astral-sh/ruff).
|
|
148
|
-
|
|
149
|
-
[20/10/2024]
|
|
150
|
-
- [v2.1.9] Do not clear the terminal before showing the progress bar.
|
|
151
|
-
- [v2.2.0] Add the ability to set a custom description for the progress bar.
|
|
152
|
-
|
|
153
|
-
[22/10/2024]
|
|
154
|
-
- [v2.2.1] Only create a log file if the `log_file` parameter is specified and always create a log file if the FFmpeg process fails.
|
|
155
|
-
|
|
156
|
-
[28/10/2024]
|
|
157
|
-
- [v2.2.2] Make printing the detected duration of the input file optional.
|
|
158
|
-
|
|
159
|
-
[29/10/2024]
|
|
160
|
-
- [v2.3.0] Set `shell=True` to support piping.
|
|
161
|
-
- [v2.3.1] Kill FFmpeg process(es) on KeyboardInterrupt
|
|
162
|
-
|
|
163
|
-
[31/10/2024]
|
|
164
|
-
- [v2.4.0] Print FFmpeg stderr if better progress information cannot be shown.
|
|
165
|
-
- [v2.4.0] Flush the stream when printing FFmpeg stderr to ensure that it is printed immediately.
|
|
166
|
-
- [v2.5.0] Add an option to print FFmpeg stderr on a new line if better progress information cannot be shown.
|
|
167
|
-
|
|
168
|
-
[11/11/2024]
|
|
169
|
-
- [v2.5.1] Print the correct log file.
|
|
170
|
-
|
|
171
|
-
[12/11/2024]
|
|
172
|
-
- [v2.5.2] Drain any remaining FFmpeg stderr after the process ends.
|
|
173
|
-
- [v2.5.3] Write FFmpeg stderr to the log file in real time.
|
|
174
|
-
- [v2.5.4] Include progress info in stderr if the duration of the input file cannot be detected.
|
|
175
|
-
- [v2.5.5] Print detected errors in the terminal and only set `shell=True` if shell operators are detected.
|
|
176
|
-
|
|
177
|
-
[13/11/2024]
|
|
178
|
-
- [v2.5.6] Detect a wider range of errors.
|
|
179
|
-
|
|
180
|
-
[18/11/2024]
|
|
181
|
-
- [v2.5.7] Fix syntax. Should fix issue #26
|
|
182
|
-
|
|
183
|
-
[19/11/2024]
|
|
184
|
-
- [v2.5.8] Remove `\n` from replacement fields in f-strings. Should fix issue #26
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as f:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="better-ffmpeg-progress",
|
|
8
|
-
version="2.
|
|
8
|
+
version="2.6.1",
|
|
9
9
|
author="GitHub.com/CrypticSignal",
|
|
10
10
|
author_email="theaudiophile@outlook.com",
|
|
11
11
|
description="Run FFmpeg & see percentage progress + ETA.",
|
|
File without changes
|
{better_ffmpeg_progress-2.5.8 → better_ffmpeg_progress-2.6.1}/better_ffmpeg_progress/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|