ffmpeg-normalize 1.36.1__tar.gz → 1.37.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.
Files changed (17) hide show
  1. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/PKG-INFO +3 -2
  2. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/README.md +2 -1
  3. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/pyproject.toml +1 -1
  4. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/__init__.py +2 -0
  5. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/_cmd_utils.py +30 -1
  6. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/LICENSE.md +0 -0
  7. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/__main__.py +0 -0
  8. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/_errors.py +0 -0
  9. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/_ffmpeg_normalize.py +0 -0
  10. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/_logger.py +0 -0
  11. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/_media_file.py +0 -0
  12. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/_presets.py +0 -0
  13. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/_streams.py +0 -0
  14. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/data/presets/music.json +0 -0
  15. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/data/presets/podcast.json +0 -0
  16. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/data/presets/streaming-video.json +0 -0
  17. {ffmpeg_normalize-1.36.1 → ffmpeg_normalize-1.37.1}/src/ffmpeg_normalize/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ffmpeg-normalize
3
- Version: 1.36.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
  ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/slhck/ffmpeg-normalize/python-package.yml)
38
38
 
39
39
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
40
- [![All Contributors](https://img.shields.io/badge/all_contributors-22-orange.svg?style=flat-square)](#contributors-)
40
+ [![All Contributors](https://img.shields.io/badge/all_contributors-23-orange.svg?style=flat-square)](#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>
@@ -5,7 +5,7 @@
5
5
  ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/slhck/ffmpeg-normalize/python-package.yml)
6
6
 
7
7
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
8
- [![All Contributors](https://img.shields.io/badge/all_contributors-22-orange.svg?style=flat-square)](#contributors-)
8
+ [![All Contributors](https://img.shields.io/badge/all_contributors-23-orange.svg?style=flat-square)](#contributors-)
9
9
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
10
10
 
11
11
  A utility for batch-normalizing audio using ffmpeg.
@@ -116,6 +116,7 @@ The only reason this project exists in its current form is because [@benjaoming]
116
116
  </tr>
117
117
  <tr>
118
118
  <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>
119
+ <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>
119
120
  </tr>
120
121
  </tbody>
121
122
  <tfoot>
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "ffmpeg-normalize"
7
- version = "1.36.1"
7
+ version = "1.37.1"
8
8
  description = "Normalize audio via ffmpeg"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -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
  ]
@@ -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()