diff --git a/src/main.ts b/src/main.ts index e7e30fc..47160ba 100644 --- a/src/main.ts +++ b/src/main.ts @@ -70,7 +70,7 @@ app.whenReady().then(() => { } }); - const duration = getVideoDuration(outFile); + const duration = await getVideoDuration(outFile); const stats = statSync(outFile); return { title: outFile, size: stats.size / 1024 / 1024, duration }; diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 3af83bd..4b654f4 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -10,9 +10,11 @@ export const getNewFilename = (ogFile: string, part: string) => { }; /** Return the duration of a video in second */ -export const getVideoDuration = (file: string) => { - const command = `${ffprobe.path} -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "${file}"`; - const durationString = child_process.execSync(command).toString().trim(); +export const getVideoDuration = async (file: string) => { + const command = `"${ffprobe.path}" -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "${file}"`; + const durationString = await execute(command).then((output) => + output.toString().trim() + ); return parseFloat(durationString); };