better-ffmpeg-progress 2.5.8__tar.gz → 2.6.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: better-ffmpeg-progress
3
- Version: 2.5.8
3
+ Version: 2.6.0
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.
@@ -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,9 +94,11 @@ class FfmpegProcess:
95
94
  )
96
95
 
97
96
  if self._print_detected_duration:
97
+ line()
98
98
  print(
99
99
  f"The duration of {self._input_filepath.name} has been detected as {self._duration_secs} seconds"
100
100
  )
101
+ line()
101
102
 
102
103
  # -nostats ensures that progress information is not sent to stderr as this info is not needed in the log file, e.g.
103
104
  # frame= 1381 fps=254 q=18.0 size= 46592KiB time=00:00:46.07 bitrate=8283.1kbits/s speed=8.47x
@@ -240,6 +241,7 @@ class FfmpegProcess:
240
241
  if self._duration_secs is not None:
241
242
  try:
242
243
  stdout = stdout_queue.get_nowait()
244
+
243
245
  if stdout:
244
246
  metric, value = stdout.split("=")
245
247
  if (
@@ -265,6 +267,7 @@ class FfmpegProcess:
265
267
 
266
268
  try:
267
269
  stderr = stderr_queue.get_nowait()
270
+
268
271
  if stderr:
269
272
  self._write_to_log_file(stderr)
270
273
 
@@ -282,8 +285,8 @@ class FfmpegProcess:
282
285
 
283
286
  except KeyboardInterrupt:
284
287
  self._kill_process_and_children(process.pid)
285
- self._write_to_log_file("\n[KeyboardInterrupt] FFmpeg process(es) killed.")
286
- sys.exit("\n[KeyboardInterrupt] FFmpeg process(es) killed.")
288
+ self._write_to_log_file("\n[KeyboardInterrupt] FFmpeg process killed.")
289
+ sys.exit("\n[KeyboardInterrupt] FFmpeg process killed.")
287
290
 
288
291
  # After the process ends, drain any remaining stderr
289
292
  while True:
@@ -309,6 +312,7 @@ class FfmpegProcess:
309
312
  def run(
310
313
  self,
311
314
  log_file: Optional[Union[str, Path]] = "ffmpeg_log.txt",
315
+ print_command=False,
312
316
  progress_bar_description: str = None,
313
317
  progress_handler: Optional[Callable] = None,
314
318
  success_handler: Optional[Callable] = None,
@@ -317,6 +321,7 @@ class FfmpegProcess:
317
321
  """
318
322
  Args:
319
323
  log_file: Optional filepath to write FFmpeg output to
324
+ print_command: Print the FFmpeg command being executed. Default: False
320
325
  progress_bar_description: Optional string to set a custom description for the progress bar
321
326
  progress_handler: Optional function which receives progress metrics
322
327
  success_handler: Optional function to handle successful completion of the FFmpeg process
@@ -330,8 +335,10 @@ class FfmpegProcess:
330
335
  with open(self._ffmpeg_log_file, "w"):
331
336
  pass
332
337
 
333
- line()
334
- print(f"Executing: {' '.join(self._ffmpeg_command)}")
338
+ if print_command:
339
+ line()
340
+
341
+ print(f"Executing: {' '.join(self._ffmpeg_command)}")
335
342
 
336
343
  if self._duration_secs and not progress_handler:
337
344
  with Progress(
@@ -355,6 +362,16 @@ class FfmpegProcess:
355
362
  task_id,
356
363
  None,
357
364
  )
365
+
366
+ if return_code == 0:
367
+ progress_bar.columns = (
368
+ TextColumn("[progress.description]{task.description}"),
369
+ )
370
+ progress_bar.update(
371
+ task_id,
372
+ description=f"✓ Processed 100% of {self._input_filepath.name}",
373
+ )
374
+
358
375
  else:
359
376
  return_code = self._start_process(
360
377
  None,
@@ -362,6 +379,12 @@ class FfmpegProcess:
362
379
  progress_handler,
363
380
  )
364
381
 
382
+ if return_code == 0:
383
+ print_with_prefix(
384
+ "FFmpeg process completed.",
385
+ "\n" if self._duration_secs is None else "",
386
+ )
387
+
365
388
  self._handle_process_ended(return_code, error_handler, success_handler)
366
389
 
367
390
  def _handle_process_ended(
@@ -385,10 +408,6 @@ class FfmpegProcess:
385
408
 
386
409
  if success_handler:
387
410
  success_handler()
388
- else:
389
- print_with_prefix(
390
- "FFmpeg process completed.", "\n" if self._duration_secs is None else ""
391
- )
392
411
 
393
412
  def _kill_process_and_children(self, proc_pid: int) -> None:
394
413
  """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.5.8
3
+ Version: 2.6.0
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.5.8",
8
+ version="2.6.0",
9
9
  author="GitHub.com/CrypticSignal",
10
10
  author_email="theaudiophile@outlook.com",
11
11
  description="Run FFmpeg & see percentage progress + ETA.",