Skip to content

Commit 8375b8e

Browse files
committed
docs: update API examples
1 parent 9d4c56c commit 8375b8e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/advanced/api.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,24 @@
33
This program has a simple API that can be used to integrate it into other Python programs.
44

55
The API docs are [available here](https://htmlpreview.github.io/?https://github.com/slhck/ffmpeg-normalize/blob/master/docs-api/ffmpeg_normalize.html).
6+
7+
## Custom Environment Variables
8+
9+
If you need to pass custom environment variables to ffmpeg (e.g., for setting `LD_LIBRARY_PATH` or other runtime configuration), use the `ffmpeg_env` context manager:
10+
11+
```python
12+
import os
13+
from ffmpeg_normalize import FFmpegNormalize, ffmpeg_env
14+
15+
# Create a custom environment with additional variables
16+
custom_env = os.environ.copy()
17+
custom_env["LD_LIBRARY_PATH"] = "/custom/lib/path"
18+
19+
# Run normalization with custom environment
20+
with ffmpeg_env(custom_env):
21+
normalizer = FFmpegNormalize()
22+
normalizer.add_media_file("input.mp4", "output.mp4")
23+
normalizer.run_normalization()
24+
```
25+
26+
The context manager is thread-safe (uses `contextvars`), so concurrent normalizations in different threads can use different environments.

0 commit comments

Comments
 (0)