Seek option removed

In discord.js v12 there was an option to seek the audio stream while playing it like this:
connection.play(stream, {seek: start})
connection.play(stream, {seek: start})
But it seems to be removed, and now there isn't a way to play a stream from a different position.
player.play(resource)
player.play(resource)
I found an old issue that has some workaround code but its a bit annoying to use, when I think it should just be an option. https://github.com/discordjs/discord.js/issues/9208 Is there any plans to add this option?
GitHub
Add seek function and audio filter by adding ffmpeg options to Audi...
Which package is this feature request for? discord.js/voice Feature Just seek, audio filter using ffmpeg. Ideal solution or implementation Add seek function and audio filter by adding ffmpeg option...
3 Replies
d.js toolkit
d.js toolkit4mo ago
- What are your intents? GuildVoiceStates is required to receive voice data! - Show what dependencies you are using -- generateDependencyReport() is exported from @discordjs/voice. - Try looking at common examples: https://github.com/discordjs/voice-examples. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
duck
duck4mo ago
afaik no to clarify, the snippet on that issue seems to overstep what's actually necessary you can just pipe through an FFmpeg transformer with the -ss flag, as ffmpeg is the only thing handling seeking since createAudioResource accepts a stream, you can just pass it the FFmpeg transform stream ffmpeg: https://trac.ffmpeg.org/wiki/Seeking prism media: https://amishshah.github.io/prism-media/core.FFmpeg.html
Moebytes
MoebytesOP4mo ago
Would it be used like this?
const readStream = fs.createReadStream(file)
const seekOpts = new FFmpeg({args: ["-ss", String(start)]})
const seekedStream = readStream.pipe(seekOpts)
const stream = createAudioResource(seekedStream, {inlineVolume: true})
const readStream = fs.createReadStream(file)
const seekOpts = new FFmpeg({args: ["-ss", String(start)]})
const seekedStream = readStream.pipe(seekOpts)
const stream = createAudioResource(seekedStream, {inlineVolume: true})
I don't really like this because it cuts the actual file and if for instance you want to loop it would loop the cut file rather than the full one. It also messes up playbackDuration and you have to track how much you seeked manually. K I guess I got it to work like before by tracking the file before seeking and the seek offset. A lot more annoying than in v12 but at least this is solved for me
Want results from more Discord servers?
Add your server