-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
ffmpeg.js
87 lines (79 loc) · 5.32 KB
/
ffmpeg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//═══════════════════════════════════════════════════════//
//╔══╗ ╔╗ ╔═══╗╔═══╗╔╗╔═╗ ╔═══╗╔═══╗╔═╗ ╔╗╔════╗╔╗ ╔╗╔═══╗╔═══╗ ╔═╗╔═╗╔═══╗
//║╔╗║ ║║ ║╔═╗║║╔═╗║║║║╔╝ ║╔═╗║║╔═╗║║║╚╗║║║╔╗╔╗║║║ ║║║╔══╝║╔═╗║ ║║╚╝║║╚╗╔╗║
//║╚╝╚╗║║ ║║ ║║║║ ╚╝║╚╝╝ ║╚═╝║║║ ║║║╔╗╚╝║╚╝║║╚╝║╚═╝║║╚══╗║╚═╝║ ║╔╗╔╗║ ║║║║
//║╔═╗║║║ ╔╗║╚═╝║║║ ╔╗║╔╗║ ║╔══╝║╚═╝║║║╚╗║║ ║║ ║╔═╗║║╔══╝║╔╗╔╝ ║║║║║║ ║║║║
//║╚═╝║║╚═╝║║╔═╗║║╚═╝║║║║╚╗ ║║ ║╔═╗║║║ ║║║ ╔╝╚╗ ║║ ║║║╚══╗║║║╚╗ ║║║║║║╔╝╚╝║
//╚═══╝╚═══╝╚╝ ╚╝╚═══╝╚╝╚═╝ ╚╝ ╚╝ ╚╝╚╝ ╚═╝ ╚══╝ ╚╝ ╚╝╚═══╝╚╝╚═╝ ╚╝╚╝╚╝╚═══╝
//════════════════════════════//
let DataPack = require('sew-queen-pro');
let SewQueen = require('sew-queen-pro/sources/dc/handler');
let Details = require('sew-queen-pro/sources/dc/Details');
let { MessageType, MessageOptions, Mimetype, GroupSettingChange, ChatModification } = require('@ravindu01manoj/sew-queen-web');
let fs = require('fs');
let { SendMessageImage } = require('sew-queen-pro/sources/dc/cmd/dl')
let os = require('os');
let ffmpeg = require('fluent-ffmpeg');
let exec = require('child_process').exec;
let axios = require('axios');
let got = require('got');
let {execFile} = require('child_process');
let cwebp = require('cwebp-bin');
let DataHelp = DataPack.constdata
let WorkType = Details.WORKTYPE == 'public' ? false : true
const DATA = DataHelp.dataGet('ffmpeg');
SewQueen['IntroduceCMD']({pattern: 'ffmpeg ?(.*)', fromMe: WorkType, desc: DATA.FF_DESC, dontAdCommandList: true}, (async (message, input) => {
if (input[1] === '') return await message.client.sendMessage(message.jid,'Need Media and Filter Name!\nℹ️ Ex: ```.ffmpeg fade=in:0:30```\nℹ️ Ex: ```.ffmpeg curves=vintage, fps=fps=25```', MessageType.text);
if (message.reply_message.video) {
var downloading = await message.client.sendMessage(message.jid,DATA.FF_PROC,MessageType.text);
var location = await message.client.downloadAndSaveMediaMessage({
key: {
remoteJid: message.reply_message.jid,
id: message.reply_message.id
},
message: message.reply_message.data.quotedMessage
});
ffmpeg(location)
.videoFilters(`${input[1]}`)
.format('mp4')
.save('output.mp4')
.on('end', async () => {
await message.sendMessage(fs.readFileSync('output.mp4'), MessageType.video, {mimetype: Mimetype.mpeg, caption: '*' + Details.CPK + '*'});
});
return await message.client.deleteMessage(message.jid, {id: downloading.key.id, remoteJid: message.jid, fromMe: true})
}
else if (message.reply_message.video === false && message.reply_message.image) {
var downloading = await message.client.sendMessage(message.jid,DATA.FF_PROC,MessageType.text);
var location = await message.client.downloadAndSaveMediaMessage({
key: {
remoteJid: message.reply_message.jid,
id: message.reply_message.id
},
message: message.reply_message.data.quotedMessage
});
ffmpeg(location)
.videoFilters(`${input[1]}`)
.save('output.jpg')
.on('end', async () => {
await SendMessageImage(message,fs.readFileSync('output.jpg'),'*' + Details.CPK + '*');
});
return await message.client.deleteMessage(message.jid, {id: downloading.key.id, remoteJid: message.jid, fromMe: true})
}
else {
var downloading = await message.client.sendMessage(message.jid,DATA.FF_PROC,MessageType.text);
var location = await message.client.downloadAndSaveMediaMessage({
key: {
remoteJid: message.reply_message.jid,
id: message.reply_message.id
},
message: message.reply_message.data.quotedMessage
});
ffmpeg(location)
.audioFilters(`${input[1]}`)
.save('output.mp3')
.on('end', async () => {
await message.sendMessage(fs.readFileSync('output.mp3'), MessageType.audio, {mimetype: Mimetype.mp4Audio});
});
return await message.client.deleteMessage(message.jid, {id: downloading.key.id, remoteJid: message.jid, fromMe: true})
}
}));