Discord.js: Seek argument is provided to FFMPEG in the wrong order

Created on 19 Dec 2018  Â·  2Comments  Â·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:
As described in #867, seeking is quite slow, and from my tests it still is now. I believe I found the problem:

The FFMPEG docs https://trac.ffmpeg.org/wiki/Seeking describe input and output seeking. Which one is performed depends on the position of the seek -ss argument. In the current code, the argument is supplied after the input argument, so output seeking is performed, which is slow. I think, with input seeking, the performance should be much better, unless I'm missing something.
So I propose to move the seek argument before the input argument.

Code in BasePlayer.js where argument is supplied:

const args = isStream ? FFMPEG_ARGUMENTS.slice() : ['-i', input, ...FFMPEG_ARGUMENTS];
if (options.seek) args.push('-ss', String(options.seek));

Change to something like:

const args = isStream ? FFMPEG_ARGUMENTS.slice() : ['-i', input, ...FFMPEG_ARGUMENTS];
if (options.seek) args.unshift('-ss', String(options.seek));

Further details:

  • discord.js version: discord.[email protected]
  • Node.js version: v8.11.4
  • Operating system: Ubuntu 18.10 VM & node:10 docker image
  • Priority this issue should have: Medium to low, I definitely appreciate this fix, as it will make seeking a lot more convenient to use
  • [x] I have also tested the issue on latest master, commit hash:
low voice bug

Most helpful comment

Great, I tested it, and even seeking to the 2 hour mark in a 24h long video is pretty fast!

All 2 comments

Fixed in the above commit :)

Great, I tested it, and even seeking to the 2 hour mark in a 24h long video is pretty fast!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Acaretia picture Acaretia  Â·  3Comments

xCuzImPro picture xCuzImPro  Â·  3Comments

Blumlaut picture Blumlaut  Â·  3Comments

Alipoodle picture Alipoodle  Â·  3Comments

shukriadams picture shukriadams  Â·  3Comments