Hi all, I'm trying to add the functionality to my music bot to allow it to play files uploaded to the guild. I've got it playing everything with createAudioResource, but the returned resource object doesn't contain the length of the audio resource. How might I get this information without downloading the file separately? Many thanks.
#Getting the length of an MP3, OGG, FLAC, WAV file posted in message
14 messages · Page 1 of 1 (latest)
• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
Documentation suggestion for @hardy elm:
AudioResource#playbackDuration
The playback duration of this audio resource, given in milliseconds.
does that not work?
that's the current duration, not total
or at least that what it looks like, given how it gets incremented during each read()
Yes, that's the elapsed time, not total length
My guess is that because AudioResource could be a stream, it doesn't provide a total length. Think I'm going to have to do some header decoding
use ffmpeg @hardy elm
Not sure how ffprobe will deal with incomplete files
I already know the offsets in the WAV file header, and FLAC isn't too hard either
there's already an npm module for estimating mp3 lengths
well there is a way using ff probe
using incomplete files?