From fe7255ba41c30fac714b2a2ffdf55b5da93c5ffa Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Wed, 22 Oct 2025 00:30:59 +0200 Subject: [PATCH] Add support for extra output args to ffmpeg --- music_assistant/helpers/ffmpeg.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/music_assistant/helpers/ffmpeg.py b/music_assistant/helpers/ffmpeg.py index 8d33a785..822ef157 100644 --- a/music_assistant/helpers/ffmpeg.py +++ b/music_assistant/helpers/ffmpeg.py @@ -38,6 +38,7 @@ class FFMpeg(AsyncProcess): filter_params: list[str] | None = None, extra_args: list[str] | None = None, extra_input_args: list[str] | None = None, + extra_output_args: list[str] | None = None, audio_output: str | int = "-", collect_log_history: bool = False, loglevel: str = "info", @@ -51,6 +52,7 @@ class FFMpeg(AsyncProcess): input_path=audio_input if isinstance(audio_input, str) else "-", output_path=audio_output if isinstance(audio_output, str) else "-", extra_input_args=extra_input_args or [], + extra_output_args=extra_output_args or [], loglevel=loglevel, ) self.audio_input = audio_input @@ -200,6 +202,7 @@ async def get_ffmpeg_stream( extra_args: list[str] | None = None, chunk_size: int | None = None, extra_input_args: list[str] | None = None, + extra_output_args: list[str] | None = None, raise_ffmpeg_exception: bool = False, ) -> AsyncGenerator[bytes, None]: """ @@ -215,6 +218,7 @@ async def get_ffmpeg_stream( filter_params=filter_params, extra_args=extra_args, extra_input_args=extra_input_args, + extra_output_args=extra_output_args, collect_log_history=True, ) as ffmpeg_proc: # read final chunks from stdout @@ -238,6 +242,7 @@ def get_ffmpeg_args( # noqa: PLR0915 input_path: str = "-", output_path: str = "-", extra_input_args: list[str] | None = None, + extra_output_args: list[str] | None = None, loglevel: str = "error", ) -> list[str]: """Collect all args to send to the ffmpeg process.""" @@ -245,6 +250,8 @@ def get_ffmpeg_args( # noqa: PLR0915 extra_args = [] if extra_input_args is None: extra_input_args = [] + if extra_output_args is None: + extra_output_args = [] # generic args generic_args = [ "ffmpeg", @@ -367,6 +374,7 @@ def get_ffmpeg_args( # noqa: PLR0915 else: raise RuntimeError("Invalid/unsupported output format specified") + output_args += extra_output_args # append the extra output args # append (final) output path at the end of the args output_args.append(output_path) -- 2.34.1