Skip to content

Commit

Permalink
fix: Subsonic: Warn when user tries to play MPEG-4 files
Browse files Browse the repository at this point in the history
Because these files can store some of their metadata at the end of the
file and we can't just hand a URL to ffmpeg to pull from (due to
subsonic API) we will fail to play M4A files with the moov atom at the
back.

Add a warning in the logs when this is attempted.

Signed-off-by: Eric B Munson <[email protected]>
  • Loading branch information
khers committed Jan 22, 2025
1 parent a2a65db commit f837121
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions music_assistant/providers/opensubsonic/sonic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,15 @@ async def get_stream_details(
raise UnsupportedFeaturedException(msg)

mime_type = item.content_type
if mime_type.endswith("mpeg"):
# For mp4 or m4a files, better to let ffmpeg detect the codec in use so mark them unknown
if mime_type.endswith("mp4"):
self.logger.warning(
"Due to the streaming method used by the subsonic API, M4A files "
"may fail. See provider documentation for more information."
)
mime_type = "?"
# For mp3 files, ffmpeg wants to be told 'mp3' instead of 'audio/mpeg'
elif mime_type.endswith("mpeg"):
mime_type = item.suffix

return StreamDetails(
Expand Down Expand Up @@ -821,7 +829,7 @@ def _streamer() -> None:
timeOffset=seek_position,
estimateContentLength=True,
) as stream:
for chunk in stream.iter_content(chunk_size=40960):
for chunk in stream.iter_content(chunk_size=4096):
asyncio.run_coroutine_threadsafe(
audio_buffer.put(chunk), self.mass.loop
).result()
Expand Down

0 comments on commit f837121

Please sign in to comment.