forked from Supositware/Haha-Yes
add scale and fps
This commit is contained in:
parent
09f7c0e93a
commit
a7a3056b16
1 changed files with 24 additions and 3 deletions
|
@ -14,11 +14,20 @@ class vid2giftCommand extends Command {
|
||||||
{
|
{
|
||||||
id: 'vid',
|
id: 'vid',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'fps',
|
||||||
|
type: 'integer'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'scale',
|
||||||
|
match: 'flag',
|
||||||
|
flag: '--scale'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
description: {
|
description: {
|
||||||
content: 'Transform video into gif',
|
content: 'Transform video into gif. --scale to scale the gif by half,',
|
||||||
usage: '[link to video]',
|
usage: '[link to video] [Number of fps]',
|
||||||
examples: ['']
|
examples: ['']
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -34,9 +43,21 @@ class vid2giftCommand extends Command {
|
||||||
const { body: buffer } = await superagent.get(vid).catch(() => {
|
const { body: buffer } = await superagent.get(vid).catch(() => {
|
||||||
return message.channel.send('An error as occured, please try again');
|
return message.channel.send('An error as occured, please try again');
|
||||||
});
|
});
|
||||||
|
let options = '';
|
||||||
|
|
||||||
|
if (args.scale) {
|
||||||
|
options = '-vf "scale=iw/2:ih/2"';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.fps) {
|
||||||
|
options += ` -r ${args.fps}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fs.writeFile(`${os.tmpdir()}/${message.id}v2g`, buffer, () => {
|
fs.writeFile(`${os.tmpdir()}/${message.id}v2g`, buffer, () => {
|
||||||
exec(`ffmpeg -i ${os.tmpdir()}/${message.id}v2g ${os.tmpdir()}/${message.id}v2g.gif -hide_banner`)
|
exec(`ffmpeg -i ${os.tmpdir()}/${message.id}v2g ${options} -r 15 ${os.tmpdir()}/${message.id}v2g.gif -hide_banner`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return message.channel.send({files: [`${os.tmpdir()}/${message.id}v2g.gif`]})
|
return message.channel.send({files: [`${os.tmpdir()}/${message.id}v2g.gif`]})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
Loading…
Reference in a new issue