Skip to content

Commit

Permalink
feat: Add support for FLAC codec (shaka-project#187)
Browse files Browse the repository at this point in the history
Co-authored-by: Joey Parrish <[email protected]>
  • Loading branch information
avelad and joeyparrish authored Nov 6, 2024
1 parent d9a3d38 commit 2edfefe
Showing 1 changed file with 5 additions and 1 deletion.
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',
},
}),
'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

0 comments on commit 2edfefe

Please sign in to comment.