remove deprecated method

This commit is contained in:
FullGreaM 2025-11-09 14:53:43 +03:00
parent a47c8bb83a
commit 852c0e2803

View File

@ -65,74 +65,6 @@ class FFMPEG {
// TODO: Supports only fromFile
});
}
async convert(fromFile) {
return await new Promise((resolve, reject) => {
const isFromFile = fromFile instanceof FromFileFFMPEG;
// TODO: Off convert method
console.trace("Deprecated. Off [ffmpeg].convert() on:");
if (isFromFile) {
return resolve(fromFile.source);
}
const returnStream = !this.isBuffer ?
this.data : Readable.from(this.data);
return resolve(returnStream);
const ffmpegArgs = !isFromFile ? [
"-i",
"pipe:0",
"-c:v",
"libx264",
"-profile:v",
"high",
"-level",
"4.1",
"-c:a",
"aac",
"-crf",
"26",
"-preset",
"medium",
"-movflags",
"+frag_keyframe+empty_moov+default_base_moof",
"-f",
"mp4",
"pipe:1",
] : fromFile.args;
//console.debug("ffmpeg", ...ffmpegArgs);
const ff = spawn("ffmpeg", ffmpegArgs);
let errData = "";
ff.stderr.on("data", (chunk) => (errData += chunk.toString()));
if (isFromFile) {
ff.on("close", (code) => {
if (code !== 0) {
return reject(new Error(`FFMPEG exited with code ${code}\n${errData}`));
}
resolve(fromFile.video);
});
return;
}
const inputStream = this.isBuffer ? Readable.from(this.data) : this.data;
inputStream.pipe(ff.stdin);
const output = new PassThrough();
ff.stdout.pipe(output);
ff.on("close", (code) => {
if (code !== 0) {
reject(new Error(`FFMPEG exited with code ${code}\n${errData}`));
}
});
ff.on("error", reject);
resolve(output);
});
}
}
module.exports = FFMPEG;