forked from Supositware/Haha-Yes
can have less violent compression
This commit is contained in:
parent
e879848c05
commit
6e64d70f0e
1 changed files with 16 additions and 3 deletions
|
@ -14,11 +14,15 @@ class vidshittifyerCommand extends Command {
|
||||||
{
|
{
|
||||||
id: 'link',
|
id: 'link',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'compresion',
|
||||||
|
type: 'string'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
description: {
|
description: {
|
||||||
content: 'Make your vid shit quality',
|
content: 'Make your vid shit quality.',
|
||||||
usage: '[link to video]',
|
usage: '[link to video] [compression ( 1, 2 or 3)]',
|
||||||
examples: ['']
|
examples: ['']
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -27,7 +31,15 @@ class vidshittifyerCommand extends Command {
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
let input = `${os.tmpdir()}/${message.id}.mp4`;
|
let input = `${os.tmpdir()}/${message.id}.mp4`;
|
||||||
let output = `${os.tmpdir()}/Shittifyed${message.id}.mp4`;
|
let output = `${os.tmpdir()}/Shittifyed${message.id}.mp4`;
|
||||||
|
let compression;
|
||||||
if (args.link) {
|
if (args.link) {
|
||||||
|
if (args.compression == 1) {
|
||||||
|
compression = '1m';
|
||||||
|
} else if (args.compression == 2) {
|
||||||
|
compression = '50k';
|
||||||
|
} else {
|
||||||
|
compression = '10k';
|
||||||
|
}
|
||||||
let video = youtubedl(args.link);
|
let video = youtubedl(args.link);
|
||||||
video.on('error', function error(err) {
|
video.on('error', function error(err) {
|
||||||
console.log('error 2:', err);
|
console.log('error 2:', err);
|
||||||
|
@ -35,8 +47,9 @@ class vidshittifyerCommand extends Command {
|
||||||
});
|
});
|
||||||
video.pipe(fs.createWriteStream(input));
|
video.pipe(fs.createWriteStream(input));
|
||||||
video.on('end', function () {
|
video.on('end', function () {
|
||||||
exec(`ffmpeg -i ${input} -b:v 10k -b:a 20k -vcodec libx264 -r 5 -r 15 ${output}`)
|
exec(`ffmpeg -i ${input} -b:v ${compression} -b:a ${compression} -vcodec libx264 -r 5 -r 15 ${output}`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
message.delete();
|
||||||
return message.channel.send({files: [output]})
|
return message.channel.send({files: [output]})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
Loading…
Reference in a new issue