serenity-rs / songbird

An async Rust library for the Discord voice API
ISC License
381 stars 108 forks source link

M3U8 support (soundcloud) #241

Closed murl-digital closed 1 week ago

murl-digital commented 2 weeks ago

Songbird version: 0.4.1

Rust version (rustc -V): rustc 1.81.0-nightly (aa1d4f682 2024-07-03)

Serenity/Twilight version: serenity 0.12

Output of ffmpeg -version, yt-dlp --version (if relevant): 2024.07.02 ...

Description: when trying to play a source from soundcloud.com, symphonia throws a no format supported error, even when enabling everything. my best guess is that soundcloud uses opus or something. ...

Steps to reproduce: ... use voice example pass in soundcloud link (e.g https://soundcloud.com/upscale-recordings/tomsbattery?) observe error thrown in logs

FelixMcFelix commented 2 weeks ago

We have full support for Opus, because we configure symphonia with a custom codec for that purpose.

The issue here is that the stream you have linked is m3u8, which we don't support:

yt-dlp -j https://soundcloud.com/upscale-recordings/tomsbattery? -f ba[abr>0][vcodec=none]/best --no-playlist | jq '{protocol, url}'
{
  "protocol": "m3u8_native",
  "url": "https://cf-hls-opus-media.sndcdn.com/playlist/594b68d6-a265-4a75-8125-da0c9d40eb14.64.opus/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1vcHVzLW1lZGlhLnNuZGNkbi5jb20vcGxheWxpc3QvNTk0YjY4ZDYtYTI2NS00YTc1LTgxMjUtZGEwYzlkNDBlYjE0LjY0Lm9wdXMvcGxheWxpc3QubTN1OCoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MjAxOTgxMDd9fX1dfQ__&Signature=HIOzUklJSPdTda6ZZ~8BZuBd4YsuX0xm4Jh88es7DcClCouT18sox4~6V8pvpRx3J12yRr6HTPzW3hvt-fIInSDYTj5eRTLbkX0bdW1-1GvBgdHcjxhO11k7m8ElERXu~bRWe3Jhb2Nv9wzE3LL7kyto3KzHkdTOnrQfFc5KPVOnj8yCljoYLFdlrg3F4wkKJ6CpFGSPVb2Q88cPb~JfFulsfVqGbwWJml4-OwOcYUIzL4SinCUrMwtIGQesNQinYoVhlra-g5ydPBMPz07pzmIfuh6qg417PFlscRlYRw8ExfdaHYJlXKT9RSzbGWrSy5ODgqrVylcAMfBo6MQQNg__&Key-Pair-Id=APKAI6TU7MMXM5DG6EPQ"
}

Practically speaking, the object that gets downloaded is a playlist which links to a set of smaller opus chunks. Handling playlists like this is probably a significant lift in terms of engineering work.

murl-digital commented 2 weeks ago

is there anything i can do to help?

Erk- commented 2 weeks ago

@murl-digital Using #242 should work, so you can try that out.

murl-digital commented 2 weeks ago

just tried it, seems to work