#Getting the length of an MP3, OGG, FLAC, WAV file posted in message

14 messages · Page 1 of 1 (latest)

hardy elm
#

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.

sudden sentinel
#

• 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.

crude mothBOT
native quail
#

does that not work?

gilded hare
#

that's the current duration, not total

#

or at least that what it looks like, given how it gets incremented during each read()

hardy elm
hardy elm
#

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

hushed kiln
#

use ffmpeg @hardy elm

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

hushed kiln
#

well there is a way using ff probe

hardy elm
#

using incomplete files?