better-ffmpeg-progress 2.1.9__tar.gz → 2.2.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.1.9 → better_ffmpeg_progress-2.2.1}/PKG-INFO +17 -8
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/README.md +16 -7
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/better_ffmpeg_progress/better_ffmpeg_progress.py +46 -28
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/better_ffmpeg_progress.egg-info/PKG-INFO +17 -8
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/setup.py +1 -1
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/LICENSE +0 -0
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/better_ffmpeg_progress/__init__.py +0 -0
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/better_ffmpeg_progress.egg-info/SOURCES.txt +0 -0
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/better_ffmpeg_progress.egg-info/dependency_links.txt +0 -0
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/better_ffmpeg_progress.egg-info/requires.txt +0 -0
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/better_ffmpeg_progress.egg-info/top_level.txt +0 -0
- {better_ffmpeg_progress-2.1.9 → better_ffmpeg_progress-2.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: better-ffmpeg-progress
|
|
3
|
-
Version: 2.1
|
|
3
|
+
Version: 2.2.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
|
|
@@ -30,11 +30,11 @@ Runs an FFmpeg command and uses [Rich](https://github.com/Textualize/rich) to sh
|
|
|
30
30
|
## Example:
|
|
31
31
|
|
|
32
32
|
```
|
|
33
|
-
⠏ Processing
|
|
33
|
+
⠏ Processing abc.webm ━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 23% 0:00:04 00:15
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
Where:
|
|
37
|
-
|
|
37
|
+
- `Processing abc.webm` is the description of the progresss bar.
|
|
38
38
|
- `23%` is the percentage progress.
|
|
39
39
|
- `0:00:04` is the time (H:MM:SS) elapsed.
|
|
40
40
|
- `00:15` is the estimated time until the FFmpeg process completes.
|
|
@@ -78,13 +78,18 @@ def handle_error():
|
|
|
78
78
|
# Pass a list of FFmpeg arguments, like you would if using subprocess.run()
|
|
79
79
|
process = FfmpegProcess(["ffmpeg", "-i", "input.mp4", "-c:a", "libmp3lame", "output.mp3"])
|
|
80
80
|
|
|
81
|
-
ffmpeg_output_path = 'ffmpeg_output.txt'
|
|
82
|
-
|
|
83
81
|
# Use the run method to run the FFmpeg command.
|
|
84
|
-
process.run(
|
|
82
|
+
process.run(
|
|
83
|
+
log_file="ffmpeg_output.txt",
|
|
84
|
+
progress_bar_description="Converting file...",
|
|
85
|
+
progress_handler=handle_progress_info,
|
|
86
|
+
success_handler=handle_success,
|
|
87
|
+
error_handler=handle_error,
|
|
88
|
+
)
|
|
85
89
|
```
|
|
86
90
|
|
|
87
91
|
The `run` method takes the following **optional** arguments:
|
|
92
|
+
- `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.
|
|
88
93
|
|
|
89
94
|
- `progress_handler`
|
|
90
95
|
|
|
@@ -96,9 +101,9 @@ The `run` method takes the following **optional** arguments:
|
|
|
96
101
|
- Estimated output filesize in bytes. [float]
|
|
97
102
|
- _Note: This is not accurate. Please take the value with a grain of salt._
|
|
98
103
|
|
|
99
|
-
The values will be `None` if unknown. The function will receive the
|
|
104
|
+
The values will be `None` if unknown. The function will receive the current values of these metrics as arguments, every 0.1s.
|
|
100
105
|
|
|
101
|
-
- `
|
|
106
|
+
- `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`.
|
|
102
107
|
|
|
103
108
|
- `success_handler` - A function to run if the FFmpeg process completes successfully.
|
|
104
109
|
|
|
@@ -151,3 +156,7 @@ The `run` method takes the following **optional** arguments:
|
|
|
151
156
|
|
|
152
157
|
[20/10/2024]
|
|
153
158
|
- [v2.1.9] Do not clear the terminal before showing the progress bar.
|
|
159
|
+
- [v2.2.0] Add the ability to set a custom description for the progress bar.
|
|
160
|
+
|
|
161
|
+
[22/10/2020]
|
|
162
|
+
- [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.
|
|
@@ -13,11 +13,11 @@ Runs an FFmpeg command and uses [Rich](https://github.com/Textualize/rich) to sh
|
|
|
13
13
|
## Example:
|
|
14
14
|
|
|
15
15
|
```
|
|
16
|
-
⠏ Processing
|
|
16
|
+
⠏ Processing abc.webm ━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 23% 0:00:04 00:15
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Where:
|
|
20
|
-
|
|
20
|
+
- `Processing abc.webm` is the description of the progresss bar.
|
|
21
21
|
- `23%` is the percentage progress.
|
|
22
22
|
- `0:00:04` is the time (H:MM:SS) elapsed.
|
|
23
23
|
- `00:15` is the estimated time until the FFmpeg process completes.
|
|
@@ -61,13 +61,18 @@ def handle_error():
|
|
|
61
61
|
# Pass a list of FFmpeg arguments, like you would if using subprocess.run()
|
|
62
62
|
process = FfmpegProcess(["ffmpeg", "-i", "input.mp4", "-c:a", "libmp3lame", "output.mp3"])
|
|
63
63
|
|
|
64
|
-
ffmpeg_output_path = 'ffmpeg_output.txt'
|
|
65
|
-
|
|
66
64
|
# Use the run method to run the FFmpeg command.
|
|
67
|
-
process.run(
|
|
65
|
+
process.run(
|
|
66
|
+
log_file="ffmpeg_output.txt",
|
|
67
|
+
progress_bar_description="Converting file...",
|
|
68
|
+
progress_handler=handle_progress_info,
|
|
69
|
+
success_handler=handle_success,
|
|
70
|
+
error_handler=handle_error,
|
|
71
|
+
)
|
|
68
72
|
```
|
|
69
73
|
|
|
70
74
|
The `run` method takes the following **optional** arguments:
|
|
75
|
+
- `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.
|
|
71
76
|
|
|
72
77
|
- `progress_handler`
|
|
73
78
|
|
|
@@ -79,9 +84,9 @@ The `run` method takes the following **optional** arguments:
|
|
|
79
84
|
- Estimated output filesize in bytes. [float]
|
|
80
85
|
- _Note: This is not accurate. Please take the value with a grain of salt._
|
|
81
86
|
|
|
82
|
-
The values will be `None` if unknown. The function will receive the
|
|
87
|
+
The values will be `None` if unknown. The function will receive the current values of these metrics as arguments, every 0.1s.
|
|
83
88
|
|
|
84
|
-
- `
|
|
89
|
+
- `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`.
|
|
85
90
|
|
|
86
91
|
- `success_handler` - A function to run if the FFmpeg process completes successfully.
|
|
87
92
|
|
|
@@ -134,3 +139,7 @@ The `run` method takes the following **optional** arguments:
|
|
|
134
139
|
|
|
135
140
|
[20/10/2024]
|
|
136
141
|
- [v2.1.9] Do not clear the terminal before showing the progress bar.
|
|
142
|
+
- [v2.2.0] Add the ability to set a custom description for the progress bar.
|
|
143
|
+
|
|
144
|
+
[22/10/2020]
|
|
145
|
+
- [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.
|
|
@@ -143,24 +143,23 @@ class FfmpegProcess:
|
|
|
143
143
|
pipe.close()
|
|
144
144
|
|
|
145
145
|
def _write_ffmpeg_output(
|
|
146
|
-
self,
|
|
146
|
+
self,
|
|
147
|
+
stderr_output: str,
|
|
148
|
+
log_file: Optional[Union[str, Path]],
|
|
149
|
+
is_error: bool = False,
|
|
147
150
|
) -> None:
|
|
148
151
|
"""Write FFmpeg stderr to a txt file."""
|
|
149
|
-
|
|
150
|
-
output_dir.mkdir(exist_ok=True)
|
|
152
|
+
Path(log_file).write_text(stderr_output)
|
|
151
153
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
if is_error:
|
|
155
|
+
return
|
|
154
156
|
|
|
155
|
-
log_file
|
|
156
|
-
print(f"Done! FFmpeg log file: {log_file}")
|
|
157
|
+
print(f"FFmpeg log written to: {log_file}")
|
|
157
158
|
|
|
158
159
|
def _start_process(
|
|
159
160
|
self,
|
|
160
161
|
progress_bar: Optional[Progress],
|
|
161
162
|
task_id: Optional[int],
|
|
162
|
-
success_handler: Optional[Callable],
|
|
163
|
-
error_handler: Optional[Callable],
|
|
164
163
|
progress_handler: Optional[Callable],
|
|
165
164
|
) -> None:
|
|
166
165
|
process = subprocess.Popen(
|
|
@@ -213,25 +212,20 @@ class FfmpegProcess:
|
|
|
213
212
|
except Empty:
|
|
214
213
|
pass
|
|
215
214
|
|
|
216
|
-
|
|
217
|
-
if error_handler:
|
|
218
|
-
error_handler()
|
|
219
|
-
else:
|
|
220
|
-
sys.exit("\nFFmpeg process failed")
|
|
221
|
-
|
|
222
|
-
if success_handler:
|
|
223
|
-
success_handler()
|
|
215
|
+
return process.returncode
|
|
224
216
|
|
|
225
217
|
def run(
|
|
226
218
|
self,
|
|
227
|
-
|
|
219
|
+
log_file: Optional[Union[str, Path]] = None,
|
|
220
|
+
progress_bar_description: str = None,
|
|
228
221
|
progress_handler: Optional[Callable] = None,
|
|
229
222
|
success_handler: Optional[Callable] = None,
|
|
230
223
|
error_handler: Optional[Callable] = None,
|
|
231
224
|
) -> None:
|
|
232
225
|
"""
|
|
233
226
|
Args:
|
|
234
|
-
|
|
227
|
+
log_file: Optional filepath to write FFmpeg output to
|
|
228
|
+
progress_bar_description: Optional string to set a custom description for the progress bar
|
|
235
229
|
progress_handler: Optional function which receives progress metrics
|
|
236
230
|
success_handler: Optional function to handle successful completion of the FFmpeg process
|
|
237
231
|
error_handler: Optional function for FFmpeg process error handling
|
|
@@ -252,23 +246,47 @@ class FfmpegProcess:
|
|
|
252
246
|
refresh_per_second=10,
|
|
253
247
|
) as progress_bar:
|
|
254
248
|
task_id = progress_bar.add_task(
|
|
255
|
-
|
|
249
|
+
progress_bar_description
|
|
250
|
+
if progress_bar_description is not None
|
|
251
|
+
else f"Processing {self._input_filepath.name}",
|
|
252
|
+
total=self._duration_secs,
|
|
256
253
|
)
|
|
257
254
|
|
|
258
|
-
self._start_process(
|
|
255
|
+
return_code = self._start_process(
|
|
259
256
|
progress_bar,
|
|
260
257
|
task_id,
|
|
261
|
-
|
|
262
|
-
error_handler,
|
|
263
|
-
progress_handler,
|
|
258
|
+
None,
|
|
264
259
|
)
|
|
265
260
|
else:
|
|
266
|
-
self._start_process(
|
|
261
|
+
return_code = self._start_process(
|
|
267
262
|
None,
|
|
268
263
|
None,
|
|
269
|
-
success_handler,
|
|
270
|
-
error_handler,
|
|
271
264
|
progress_handler,
|
|
272
265
|
)
|
|
273
266
|
|
|
274
|
-
self.
|
|
267
|
+
self._handle_process_ended(
|
|
268
|
+
return_code, error_handler, success_handler, log_file
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
def _handle_process_ended(
|
|
272
|
+
self, return_code, error_handler, success_handler, log_file
|
|
273
|
+
):
|
|
274
|
+
if return_code != 0:
|
|
275
|
+
if error_handler:
|
|
276
|
+
error_handler()
|
|
277
|
+
|
|
278
|
+
ffmpeg_log_file = "ffmpeg_log.txt"
|
|
279
|
+
|
|
280
|
+
self._write_ffmpeg_output(
|
|
281
|
+
"\n".join(self._ffmpeg_stderr), ffmpeg_log_file, is_error=True
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
sys.exit(f"FFmpeg process failed. Check out {ffmpeg_log_file} for details")
|
|
285
|
+
|
|
286
|
+
if log_file:
|
|
287
|
+
self._write_ffmpeg_output("\n".join(self._ffmpeg_stderr), log_file)
|
|
288
|
+
|
|
289
|
+
if success_handler:
|
|
290
|
+
success_handler()
|
|
291
|
+
else:
|
|
292
|
+
print("FFmpeg process completed.")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: better-ffmpeg-progress
|
|
3
|
-
Version: 2.1
|
|
3
|
+
Version: 2.2.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
|
|
@@ -30,11 +30,11 @@ Runs an FFmpeg command and uses [Rich](https://github.com/Textualize/rich) to sh
|
|
|
30
30
|
## Example:
|
|
31
31
|
|
|
32
32
|
```
|
|
33
|
-
⠏ Processing
|
|
33
|
+
⠏ Processing abc.webm ━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 23% 0:00:04 00:15
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
Where:
|
|
37
|
-
|
|
37
|
+
- `Processing abc.webm` is the description of the progresss bar.
|
|
38
38
|
- `23%` is the percentage progress.
|
|
39
39
|
- `0:00:04` is the time (H:MM:SS) elapsed.
|
|
40
40
|
- `00:15` is the estimated time until the FFmpeg process completes.
|
|
@@ -78,13 +78,18 @@ def handle_error():
|
|
|
78
78
|
# Pass a list of FFmpeg arguments, like you would if using subprocess.run()
|
|
79
79
|
process = FfmpegProcess(["ffmpeg", "-i", "input.mp4", "-c:a", "libmp3lame", "output.mp3"])
|
|
80
80
|
|
|
81
|
-
ffmpeg_output_path = 'ffmpeg_output.txt'
|
|
82
|
-
|
|
83
81
|
# Use the run method to run the FFmpeg command.
|
|
84
|
-
process.run(
|
|
82
|
+
process.run(
|
|
83
|
+
log_file="ffmpeg_output.txt",
|
|
84
|
+
progress_bar_description="Converting file...",
|
|
85
|
+
progress_handler=handle_progress_info,
|
|
86
|
+
success_handler=handle_success,
|
|
87
|
+
error_handler=handle_error,
|
|
88
|
+
)
|
|
85
89
|
```
|
|
86
90
|
|
|
87
91
|
The `run` method takes the following **optional** arguments:
|
|
92
|
+
- `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.
|
|
88
93
|
|
|
89
94
|
- `progress_handler`
|
|
90
95
|
|
|
@@ -96,9 +101,9 @@ The `run` method takes the following **optional** arguments:
|
|
|
96
101
|
- Estimated output filesize in bytes. [float]
|
|
97
102
|
- _Note: This is not accurate. Please take the value with a grain of salt._
|
|
98
103
|
|
|
99
|
-
The values will be `None` if unknown. The function will receive the
|
|
104
|
+
The values will be `None` if unknown. The function will receive the current values of these metrics as arguments, every 0.1s.
|
|
100
105
|
|
|
101
|
-
- `
|
|
106
|
+
- `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`.
|
|
102
107
|
|
|
103
108
|
- `success_handler` - A function to run if the FFmpeg process completes successfully.
|
|
104
109
|
|
|
@@ -151,3 +156,7 @@ The `run` method takes the following **optional** arguments:
|
|
|
151
156
|
|
|
152
157
|
[20/10/2024]
|
|
153
158
|
- [v2.1.9] Do not clear the terminal before showing the progress bar.
|
|
159
|
+
- [v2.2.0] Add the ability to set a custom description for the progress bar.
|
|
160
|
+
|
|
161
|
+
[22/10/2020]
|
|
162
|
+
- [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.
|
|
@@ -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.1
|
|
8
|
+
version="2.2.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.1.9 → better_ffmpeg_progress-2.2.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
|