From 73b4a2fe0ba3bc3d893000058d8d6be78c1d3d34 Mon Sep 17 00:00:00 2001 From: Amber McQuilkin Date: Sun, 21 Dec 2025 20:26:58 -0800 Subject: [PATCH 1/2] Add env parameter to FFmpegPCMAudio and FFmpegOpusAudio --- discord/player.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/discord/player.py b/discord/player.py index 6243c0417..057a86b68 100644 --- a/discord/player.py +++ b/discord/player.py @@ -37,7 +37,7 @@ import sys import re import io -from typing import Any, Callable, Generic, IO, Optional, TYPE_CHECKING, Tuple, TypeVar, Union +from typing import Any, Callable, Generic, IO, Mapping, Optional, TYPE_CHECKING, Tuple, TypeVar, Union from .enums import SpeakingState from .errors import ClientException @@ -300,6 +300,8 @@ class FFmpegPCMAudio(FFmpegAudio): to the stdin of ffmpeg. Defaults to ``False``. stderr: Optional[:term:`py:file object`] A file-like object to pass to the Popen constructor. + env: Optional[:class:`Mapping[:class:`str`, :class:`str`]`] + A :class:`Mapping` that defines the environment variables for the Popen constructor. before_options: Optional[:class:`str`] Extra command line arguments to pass to ffmpeg before the ``-i`` flag. options: Optional[:class:`str`] @@ -318,11 +320,12 @@ class FFmpegPCMAudio(FFmpegAudio): executable: str = 'ffmpeg', pipe: bool = False, stderr: Optional[IO[bytes]] = None, + env: Optional[Mapping[str, str]] = None, before_options: Optional[str] = None, options: Optional[str] = None, ) -> None: args = [] - subprocess_kwargs = {'stdin': subprocess.PIPE if pipe else subprocess.DEVNULL, 'stderr': stderr} + subprocess_kwargs = {'stdin': subprocess.PIPE if pipe else subprocess.DEVNULL, 'stderr': stderr, 'env': env} if isinstance(before_options, str): args.extend(shlex.split(before_options)) @@ -410,6 +413,8 @@ class FFmpegOpusAudio(FFmpegAudio): to the stdin of ffmpeg. Defaults to ``False``. stderr: Optional[:term:`py:file object`] A file-like object to pass to the Popen constructor. + env: Optional[:class:`Mapping[:class:`str`, :class:`str`]`] + A :class:`Mapping` that defines the environment variables for the Popen constructor. before_options: Optional[:class:`str`] Extra command line arguments to pass to ffmpeg before the ``-i`` flag. options: Optional[:class:`str`] @@ -430,11 +435,12 @@ class FFmpegOpusAudio(FFmpegAudio): executable: str = 'ffmpeg', pipe: bool = False, stderr: Optional[IO[bytes]] = None, + env: Optional[Mapping[str, str]] = None, before_options: Optional[str] = None, options: Optional[str] = None, ) -> None: args = [] - subprocess_kwargs = {'stdin': subprocess.PIPE if pipe else subprocess.DEVNULL, 'stderr': stderr} + subprocess_kwargs = {'stdin': subprocess.PIPE if pipe else subprocess.DEVNULL, 'stderr': stderr, 'env': env} if isinstance(before_options, str): args.extend(shlex.split(before_options)) From 1bf139358d6a999741041d7e5743e7d3a92ae200 Mon Sep 17 00:00:00 2001 From: Amber McQuilkin Date: Sun, 21 Dec 2025 20:51:38 -0800 Subject: [PATCH 2/2] Fixed docstrings for new parameters --- discord/player.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord/player.py b/discord/player.py index 057a86b68..196e701a9 100644 --- a/discord/player.py +++ b/discord/player.py @@ -300,7 +300,7 @@ class FFmpegPCMAudio(FFmpegAudio): to the stdin of ffmpeg. Defaults to ``False``. stderr: Optional[:term:`py:file object`] A file-like object to pass to the Popen constructor. - env: Optional[:class:`Mapping[:class:`str`, :class:`str`]`] + env: Optional[Mapping[:class:`str`, :class:`str`]] A :class:`Mapping` that defines the environment variables for the Popen constructor. before_options: Optional[:class:`str`] Extra command line arguments to pass to ffmpeg before the ``-i`` flag. @@ -413,7 +413,7 @@ class FFmpegOpusAudio(FFmpegAudio): to the stdin of ffmpeg. Defaults to ``False``. stderr: Optional[:term:`py:file object`] A file-like object to pass to the Popen constructor. - env: Optional[:class:`Mapping[:class:`str`, :class:`str`]`] + env: Optional[Mapping[:class:`str`, :class:`str`]] A :class:`Mapping` that defines the environment variables for the Popen constructor. before_options: Optional[:class:`str`] Extra command line arguments to pass to ffmpeg before the ``-i`` flag.