Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for FLAC codec #187

Merged
merged 5 commits into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion streamer/bitrate_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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(
Expand Down Expand Up @@ -154,6 +155,7 @@ def _sortable_properties(self) -> Tuple[float]:
'opus': '32k',
'ac3': '96k',
'eac3': '48k',
'flac': '705k',
joeyparrish marked this conversation as resolved.
Show resolved Hide resolved
},
}),
'stereo': AudioChannelLayout({
Expand All @@ -163,6 +165,7 @@ def _sortable_properties(self) -> Tuple[float]:
'opus': '64k',
'ac3': '192k',
'eac3': '96k',
'flac': '1410k',
},
}),
'surround': AudioChannelLayout({
Expand All @@ -172,6 +175,7 @@ def _sortable_properties(self) -> Tuple[float]:
'opus': '128k',
'ac3': '384k',
'eac3': '192k',
'flac': '4230k',
},
}),
}
Expand Down