From 2edfefe43179d97ebe64d0c72ef3d43ce9499f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Wed, 6 Nov 2024 10:16:57 +0100 Subject: [PATCH] feat: Add support for FLAC codec (#187) Co-authored-by: Joey Parrish --- streamer/bitrate_configuration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/streamer/bitrate_configuration.py b/streamer/bitrate_configuration.py index b3fc455..e90b401 100644 --- a/streamer/bitrate_configuration.py +++ b/streamer/bitrate_configuration.py @@ -41,6 +41,7 @@ class AudioCodec(enum.Enum): OPUS: str = 'opus' AC3: str = 'ac3' EAC3: str = 'eac3' + FLAC: str = 'flac' def is_hardware_accelerated(self) -> bool: """Returns True if this codec is hardware accelerated.""" @@ -60,7 +61,7 @@ def get_ffmpeg_codec_string(self, hwaccel_api: str) -> str: def get_output_format(self) -> str: """Returns an FFmpeg output format suitable for this codec.""" # TODO(#31): add support for configurable output format per-codec - if (self == AudioCodec.OPUS) or (self == AudioCodec.AAC) or (self == AudioCodec.AC3) or (self == AudioCodec.EAC3): + if self in {AudioCodec.OPUS, AudioCodec.AAC, AudioCodec.AC3, AudioCodec.EAC3, AudioCodec.FLAC}: return 'mp4' else: assert False, 'No mapping for output format for codec {}'.format( @@ -154,6 +155,7 @@ def _sortable_properties(self) -> Tuple[float]: 'opus': '32k', 'ac3': '96k', 'eac3': '48k', + 'flac': '705k', }, }), 'stereo': AudioChannelLayout({ @@ -163,6 +165,7 @@ def _sortable_properties(self) -> Tuple[float]: 'opus': '64k', 'ac3': '192k', 'eac3': '96k', + 'flac': '1410k', }, }), 'surround': AudioChannelLayout({ @@ -172,6 +175,7 @@ def _sortable_properties(self) -> Tuple[float]: 'opus': '128k', 'ac3': '384k', 'eac3': '192k', + 'flac': '4230k', }, }), }