Compare commits
No commits in common. "1ea8a6f26e57c32b97dd8e91866dfaba937e9fb8" and "7926820e70bc66c4504f1c63d571e971e01ed2c4" have entirely different histories.
1ea8a6f26e
...
7926820e70
2 changed files with 3 additions and 24 deletions
|
@ -21,7 +21,7 @@ export default {
|
||||||
.setRequired(false))
|
.setRequired(false))
|
||||||
.addIntegerOption(option =>
|
.addIntegerOption(option =>
|
||||||
option.setName('fps')
|
option.setName('fps')
|
||||||
.setDescription('Change the speed at which the gif play at. Number between 1 and 100.')
|
.setDescription('Change the speed at which the gif play at. Default 20. Number between 1 and 100.')
|
||||||
.setRequired(false))
|
.setRequired(false))
|
||||||
.addBooleanOption(option =>
|
.addBooleanOption(option =>
|
||||||
option.setName('autocrop')
|
option.setName('autocrop')
|
||||||
|
@ -81,18 +81,13 @@ export default {
|
||||||
await utils.autoCrop(oldOutput, output);
|
await utils.autoCrop(oldOutput, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the fps of the original video
|
|
||||||
if (!args.fps) {
|
|
||||||
args.fps = getVideoFramerate(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
const gifskiOutput = output.replace(path.extname(output), '.gif');
|
const gifskiOutput = output.replace(path.extname(output), '.gif');
|
||||||
const gifsicleOutput = output.replace(path.extname(output), 'gifsicle.gif');
|
const gifsicleOutput = output.replace(path.extname(output), 'gifsicle.gif');
|
||||||
|
|
||||||
// Extract every frame for gifski
|
// Extract every frame for gifski
|
||||||
await utils.ffmpeg(['-i', output, `${os.tmpdir()}/frame${interaction.id}%04d.png`]);
|
await utils.ffmpeg(['-i', output, `${os.tmpdir()}/frame${interaction.id}%04d.png`]);
|
||||||
// Make it look better
|
// Make it look better
|
||||||
await gifski(gifskiOutput, `${os.tmpdir()}/frame${interaction.id}*`, quality, await args.fps);
|
await gifski(gifskiOutput, `${os.tmpdir()}/frame${interaction.id}*`, quality, args.fps);
|
||||||
// Optimize it
|
// Optimize it
|
||||||
await gifsicle(gifskiOutput, gifsicleOutput, args.noloop);
|
await gifsicle(gifskiOutput, gifsicleOutput, args.noloop);
|
||||||
|
|
||||||
|
@ -148,19 +143,3 @@ async function gifsicle(input, output, loop = false) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getVideoFramerate(input) {
|
|
||||||
return await new Promise((resolve, reject) => {
|
|
||||||
execFile('ffprobe', ['-v', 'error', '-of', 'csv=p=0', '-select_streams', 'v:0', '-show_entries', 'stream=r_frame_rate', input], (err, stdout, stderr) => {
|
|
||||||
if (err) {
|
|
||||||
reject(stderr);
|
|
||||||
}
|
|
||||||
if (stderr) {
|
|
||||||
console.error(stderr);
|
|
||||||
}
|
|
||||||
const tempfps = stdout.trim().split('/');
|
|
||||||
const fps = tempfps[0] / tempfps[1];
|
|
||||||
return resolve(fps);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -15,7 +15,7 @@ export default {
|
||||||
};
|
};
|
||||||
async function downloadVideo(urlArg, output, format = `bestvideo[height<=?${ytdlpMaxResolution}]+bestaudio/best`) {
|
async function downloadVideo(urlArg, output, format = `bestvideo[height<=?${ytdlpMaxResolution}]+bestaudio/best`) {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
const options = ['-f', format, urlArg, '-o', `${os.tmpdir()}/${output}.%(ext)s`, '--force-overwrites', '--playlist-reverse', '--no-playlist', '--remux-video=mp4/webm/mov', '--no-warnings'];
|
const options = ['-f', format, urlArg, '-o', `${os.tmpdir()}/${output}.%(ext)s`, '--force-overwrites', '--no-playlist', '--remux-video=mp4/webm/mov', '--no-warnings'];
|
||||||
if (proxy) {
|
if (proxy) {
|
||||||
options.push('--proxy');
|
options.push('--proxy');
|
||||||
options.push(proxy);
|
options.push(proxy);
|
||||||
|
|
Loading…
Reference in a new issue