-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathburnInSubtitles.ts
More file actions
23 lines (21 loc) · 737 Bytes
/
Copy pathburnInSubtitles.ts
File metadata and controls
23 lines (21 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import ffmpeg from "fluent-ffmpeg";
import ffmpegInstaller from "@ffmpeg-installer/ffmpeg";
import { splitFilePath } from "./splitFilePath";
import { join } from "path";
ffmpeg.setFfmpegPath(ffmpegInstaller.path);
export function burnInSubtitles(filePath: string, subPath: string) {
const { pathWithoutExtension } = splitFilePath(subPath);
const { extension } = splitFilePath(filePath);
const outFile = `${pathWithoutExtension}-with-burned-subs${extension}`;
return new Promise((resolve, reject) => {
ffmpeg(filePath)
.videoFilter("subtitles=" + subPath)
.on("error", function (err) {
reject(err);
})
.save(outFile)
.on("end", function () {
resolve(outFile);
});
});
}