Skip to content

Commit

Permalink
Fixed Update
Browse files Browse the repository at this point in the history
  • Loading branch information
HBMods-OFC authored Dec 29, 2024
1 parent b1b0963 commit 25dd305
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 16 additions & 1 deletion lib/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { spawn } = require('child_process')
function ffmpeg(buffer, args = [], ext = '', ext2 = '') {
return new Promise(async (resolve, reject) => {
try {
let tmp = path.join(__dirname, '../asset/trash', + new Date + '.' + ext)
let tmp = path.join(__dirname, '../asset/trash/', + new Date + '.' + ext)
let out = tmp + '.' + ext2
await fs.promises.writeFile(tmp, buffer)
spawn('ffmpeg', [
Expand All @@ -31,6 +31,11 @@ function ffmpeg(buffer, args = [], ext = '', ext2 = '') {
})
}

/**
* Convert Audio to Playable WhatsApp Audio
* @param {Buffer} buffer Audio Buffer
* @param {String} ext File Extension
*/
function toAudio(buffer, ext) {
return ffmpeg(buffer, [
'-vn',
Expand All @@ -41,6 +46,11 @@ function toAudio(buffer, ext) {
], ext, 'mp3')
}

/**
* Convert Audio to Playable WhatsApp PTT
* @param {Buffer} buffer Audio Buffer
* @param {String} ext File Extension
*/
function toPTT(buffer, ext) {
return ffmpeg(buffer, [
'-vn',
Expand All @@ -51,6 +61,11 @@ function toPTT(buffer, ext) {
], ext, 'opus')
}

/**
* Convert Audio to Playable WhatsApp Video
* @param {Buffer} buffer Video Buffer
* @param {String} ext File Extension
*/
function toVideo(buffer, ext) {
return ffmpeg(buffer, [
'-c:v', 'libx264',
Expand Down
4 changes: 3 additions & 1 deletion lib/exif.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const fs = require('fs')
const { tmpdir } = require("os")
const Crypto = require("crypto")
const ff = require('fluent-ffmpeg-7')
const ff = require('fluent-ffmpeg')
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const webp = require("node-webpmux")
const path = require("path")
ff.setFfmpegPath(ffmpegPath);


async function imageToWebp (media) {
Expand Down

0 comments on commit 25dd305

Please sign in to comment.