From: Marcel van der Veldt Date: Thu, 29 Aug 2024 22:36:44 +0000 (+0200) Subject: small changes for streams handling X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=67db76fe62edb0bca215eecd54b81899e40f74ff;p=music-assistant-server.git small changes for streams handling --- diff --git a/music_assistant/server/controllers/streams.py b/music_assistant/server/controllers/streams.py index e35deaef..2a179adf 100644 --- a/music_assistant/server/controllers/streams.py +++ b/music_assistant/server/controllers/streams.py @@ -41,6 +41,7 @@ from music_assistant.constants import ( CONF_OUTPUT_CHANNELS, CONF_PUBLISH_IP, CONF_SAMPLE_RATES, + MASS_LOGO_ONLINE, SILENCE_FILE, VERBOSE_LOG_LEVEL, ) @@ -77,8 +78,12 @@ DEFAULT_STREAM_HEADERS = { "Pragma": "no-cache", "Connection": "close", "Accept-Ranges": "none", - "Icy-Name": "Music Assistant", - "Icy-Url": "https://music-assistant.io", +} +ICY_HEADERS = { + "icy-name": "Music Assistant", + "icy-description": "Music Assistant - Your personal music assistant", + "icy-version": "1", + "icy-logo": MASS_LOGO_ONLINE, } FLOW_DEFAULT_SAMPLE_RATE = 48000 FLOW_DEFAULT_BIT_DEPTH = 24 @@ -303,6 +308,7 @@ class StreamsController(CoreController): "Accept-Ranges": "none", "Cache-Control": "no-cache", "Connection": "close", + "icy-name": queue_item.name, } resp = web.StreamResponse( status=200, @@ -390,6 +396,7 @@ class StreamsController(CoreController): # prepare request, add some DLNA/UPNP compatible headers headers = { **DEFAULT_STREAM_HEADERS, + **ICY_HEADERS, "Content-Type": f"audio/{output_format.output_format_str}", "Accept-Ranges": "none", "Cache-Control": "no-cache", @@ -944,6 +951,9 @@ class StreamsController(CoreController): player.player_id, CONF_OUTPUT_CHANNELS, "stereo" ) output_channels = 1 if output_channels_str != "stereo" else 2 + if not content_type.is_lossless(): + output_bit_depth = 16 + output_sample_rate = min(48000, output_sample_rate) return AudioFormat( content_type=content_type, sample_rate=output_sample_rate, diff --git a/music_assistant/server/helpers/audio.py b/music_assistant/server/helpers/audio.py index b5fb2104..be806928 100644 --- a/music_assistant/server/helpers/audio.py +++ b/music_assistant/server/helpers/audio.py @@ -944,7 +944,9 @@ def get_ffmpeg_args( elif output_format.content_type == ContentType.UNKNOWN: raise RuntimeError("Invalid output format specified") elif output_format.content_type == ContentType.AAC: - output_args = ["-f", "adts", output_path] + output_args = ["-f", "adts", "-c:a", "aac", "-b:a", "256k", output_path] + elif output_format.content_type == ContentType.MP3: + output_args = ["-f", "mp3", "-b:a", "320k", output_path] else: if output_format.content_type.is_pcm(): output_args += ["-acodec", output_format.content_type.name.lower()] @@ -958,6 +960,8 @@ def get_ffmpeg_args( str(output_format.channels), output_path, ] + if output_format.output_format_str == "flac": + output_args += ["-compression_level", "6"] # edge case: source file is not stereo - downmix to stereo if input_format.channels > 2 and output_format.channels == 2: