11 lines
309 B
TypeScript
11 lines
309 B
TypeScript
|
|
import ffmpeg from "fluent-ffmpeg";
|
||
|
|
|
||
|
|
export function extractDuration(filePath: string): Promise<number> {
|
||
|
|
return new Promise((resolve, reject) => {
|
||
|
|
ffmpeg.ffprobe(filePath, (err, metadata) => {
|
||
|
|
if (err) return reject(err);
|
||
|
|
resolve(Math.round(metadata.format.duration || 0));
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|