ffmpeg-normalize 1.36.1__py3-none-any.whl → 1.37.1__py3-none-any.whl
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.
- ffmpeg_normalize/__init__.py +2 -0
- ffmpeg_normalize/_cmd_utils.py +30 -1
- {ffmpeg_normalize-1.36.1.dist-info → ffmpeg_normalize-1.37.1.dist-info}/METADATA +3 -2
- {ffmpeg_normalize-1.36.1.dist-info → ffmpeg_normalize-1.37.1.dist-info}/RECORD +7 -7
- {ffmpeg_normalize-1.36.1.dist-info → ffmpeg_normalize-1.37.1.dist-info}/WHEEL +0 -0
- {ffmpeg_normalize-1.36.1.dist-info → ffmpeg_normalize-1.37.1.dist-info}/entry_points.txt +0 -0
- {ffmpeg_normalize-1.36.1.dist-info → ffmpeg_normalize-1.37.1.dist-info}/licenses/LICENSE.md +0 -0
ffmpeg_normalize/__init__.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import importlib.metadata
|
|
2
2
|
|
|
3
|
+
from ._cmd_utils import ffmpeg_env
|
|
3
4
|
from ._errors import FFmpegNormalizeError
|
|
4
5
|
from ._ffmpeg_normalize import FFmpegNormalize
|
|
5
6
|
from ._media_file import MediaFile
|
|
@@ -17,5 +18,6 @@ __all__ = [
|
|
|
17
18
|
"VideoStream",
|
|
18
19
|
"SubtitleStream",
|
|
19
20
|
"MediaStream",
|
|
21
|
+
"ffmpeg_env",
|
|
20
22
|
"__version__",
|
|
21
23
|
]
|
ffmpeg_normalize/_cmd_utils.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import contextvars
|
|
3
4
|
import logging
|
|
4
5
|
import os
|
|
5
6
|
import re
|
|
6
7
|
import shlex
|
|
7
8
|
import subprocess
|
|
9
|
+
from contextlib import contextmanager
|
|
8
10
|
from shutil import which
|
|
9
11
|
from typing import Any, Iterator
|
|
10
12
|
|
|
@@ -14,6 +16,30 @@ from ._errors import FFmpegNormalizeError
|
|
|
14
16
|
|
|
15
17
|
_logger = logging.getLogger(__name__)
|
|
16
18
|
|
|
19
|
+
_ffmpeg_env_var: contextvars.ContextVar[dict[str, str] | None] = contextvars.ContextVar(
|
|
20
|
+
"ffmpeg_env", default=None
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@contextmanager
|
|
25
|
+
def ffmpeg_env(env: dict[str, str] | None) -> Iterator[None]:
|
|
26
|
+
"""
|
|
27
|
+
Temporarily set the environment for subprocess.Popen.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
env: Environment dict to pass to subprocess.Popen.
|
|
31
|
+
"""
|
|
32
|
+
token = _ffmpeg_env_var.set(env)
|
|
33
|
+
try:
|
|
34
|
+
yield
|
|
35
|
+
finally:
|
|
36
|
+
_ffmpeg_env_var.reset(token)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _get_ffmpeg_env() -> dict[str, str] | None:
|
|
40
|
+
return _ffmpeg_env_var.get()
|
|
41
|
+
|
|
42
|
+
|
|
17
43
|
DUR_REGEX = re.compile(
|
|
18
44
|
r"Duration: (?P<hour>\d{2}):(?P<min>\d{2}):(?P<sec>\d{2})\.(?P<ms>\d{2})"
|
|
19
45
|
)
|
|
@@ -76,7 +102,9 @@ class CommandRunner:
|
|
|
76
102
|
# wrapper for 'ffmpeg-progress-yield'
|
|
77
103
|
_logger.debug(f"Running command: {shlex.join(cmd)}")
|
|
78
104
|
with FfmpegProgress(cmd, dry_run=self.dry) as ff:
|
|
79
|
-
yield from ff.run_command_with_progress(
|
|
105
|
+
yield from ff.run_command_with_progress(
|
|
106
|
+
popen_kwargs={"env": _get_ffmpeg_env()}
|
|
107
|
+
)
|
|
80
108
|
|
|
81
109
|
self.output = ff.stderr
|
|
82
110
|
|
|
@@ -107,6 +135,7 @@ class CommandRunner:
|
|
|
107
135
|
stdout=subprocess.PIPE,
|
|
108
136
|
stderr=subprocess.PIPE,
|
|
109
137
|
universal_newlines=False,
|
|
138
|
+
env=_get_ffmpeg_env(),
|
|
110
139
|
)
|
|
111
140
|
|
|
112
141
|
stdout_bytes, stderr_bytes = p.communicate()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ffmpeg-normalize
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.37.1
|
|
4
4
|
Summary: Normalize audio via ffmpeg
|
|
5
5
|
Keywords: ffmpeg,normalize,audio
|
|
6
6
|
Author: Werner Robitza
|
|
@@ -37,7 +37,7 @@ Description-Content-Type: text/markdown
|
|
|
37
37
|

|
|
38
38
|
|
|
39
39
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
40
|
-
[](#contributors-)
|
|
41
41
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
42
42
|
|
|
43
43
|
A utility for batch-normalizing audio using ffmpeg.
|
|
@@ -148,6 +148,7 @@ The only reason this project exists in its current form is because [@benjaoming]
|
|
|
148
148
|
</tr>
|
|
149
149
|
<tr>
|
|
150
150
|
<td align="center" valign="top" width="14.28%"><a href="https://davidbern.com/"><img src="https://avatars.githubusercontent.com/u/371066?v=4?s=100" width="100px;" alt="David Bern"/><br /><sub><b>David Bern</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=odie5533" title="Code">💻</a></td>
|
|
151
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/randompersona1"><img src="https://avatars.githubusercontent.com/u/74961116?v=4?s=100" width="100px;" alt="randompersona1"/><br /><sub><b>randompersona1</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=randompersona1" title="Code">💻</a></td>
|
|
151
152
|
</tr>
|
|
152
153
|
</tbody>
|
|
153
154
|
<tfoot>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
ffmpeg_normalize/__init__.py,sha256=
|
|
1
|
+
ffmpeg_normalize/__init__.py,sha256=FXJzAZSSg7CTNyicBcY7cOZVnhBsMET80SLdwvzvsY8,561
|
|
2
2
|
ffmpeg_normalize/__main__.py,sha256=U77hAgn7_w2QErUEocf6tal-7v-lJR7GbUQW8L-FmC0,26357
|
|
3
|
-
ffmpeg_normalize/_cmd_utils.py,sha256=
|
|
3
|
+
ffmpeg_normalize/_cmd_utils.py,sha256=A4cFo7sUccV_2OL2yHjZmocvVOj7nf5fiD_6Yw9gSPk,8450
|
|
4
4
|
ffmpeg_normalize/_errors.py,sha256=brTQ4osJ4fTA8wnyMPVVYfGwJ0wqeShRFydTEwi_VEY,48
|
|
5
5
|
ffmpeg_normalize/_ffmpeg_normalize.py,sha256=tcO_nJvsNiucsCJJcMESYsb8GbThcyhniIl21JmxNn0,22190
|
|
6
6
|
ffmpeg_normalize/_logger.py,sha256=3Ap4Fxg7xGrzz7h4IGuNEf0KKstx0Rq_eLbHPrHzcrI,1841
|
|
@@ -11,8 +11,8 @@ ffmpeg_normalize/data/presets/music.json,sha256=rKtIKAD7jlMvnGRsx6QAyPHvrGu-Ecq4
|
|
|
11
11
|
ffmpeg_normalize/data/presets/podcast.json,sha256=spMBZ_tbfU81NF6o7ZUMyQmQ7kPz3jJ1GKH-hcRmt4s,132
|
|
12
12
|
ffmpeg_normalize/data/presets/streaming-video.json,sha256=Uy4QR0kSla4vXEqctZj26-8f_eS4SQxQWQ9zI_x5QBw,132
|
|
13
13
|
ffmpeg_normalize/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
ffmpeg_normalize-1.
|
|
15
|
-
ffmpeg_normalize-1.
|
|
16
|
-
ffmpeg_normalize-1.
|
|
17
|
-
ffmpeg_normalize-1.
|
|
18
|
-
ffmpeg_normalize-1.
|
|
14
|
+
ffmpeg_normalize-1.37.1.dist-info/licenses/LICENSE.md,sha256=ig-_YggmJGbPQC_gUgBNFa0_XMsuHTpocivFnlOF4tE,1082
|
|
15
|
+
ffmpeg_normalize-1.37.1.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
16
|
+
ffmpeg_normalize-1.37.1.dist-info/entry_points.txt,sha256=1bdrW7-kJRc8tctjnGcfe_Fwx39z5JOm0yZnJHnmwl8,69
|
|
17
|
+
ffmpeg_normalize-1.37.1.dist-info/METADATA,sha256=-byArQ6qIdZoiihR9z7slwvxKO6gCHY5CJFJ2r5LQeY,14296
|
|
18
|
+
ffmpeg_normalize-1.37.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|