diff --git a/package.json b/package.json index 2f7843d..e8c36c0 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,10 @@ "config": { "forge": { "packagerConfig": { - "icon": "./image/icon.ico" + "icon": "./image/icon.ico", + "asar": { + "unpack": "**/node_modules/*-static/**" + } }, "makers": [ { diff --git a/src/main.ts b/src/main.ts index bfb0042..107a470 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,7 +11,9 @@ import { processes, } from "./utils/misc"; import path = require("path"); -import ffmpegPath = require("ffmpeg-static"); + +import ffmpeg = require("ffmpeg-static"); +const ffmpegPath = `${ffmpeg}`.replace("app.asar", "app.asar.unpacked"); const kill = require("terminate"); diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 9f10d58..c372635 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -1,9 +1,11 @@ -import ffprobe = require("ffprobe-static"); import child_process = require("child_process"); import path = require("path"); import { BrowserWindow } from "electron"; import { existsSync, unlink } from "fs"; +import ffprobe = require("ffprobe-static"); +const ffprobePath = ffprobe.path.replace("app.asar", "app.asar.unpacked"); + export const processes: child_process.ChildProcess[] = []; /** Create a new filename from the OG one */ @@ -14,14 +16,14 @@ 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 command = `"${ffprobePath}" -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "${file}"`; const durationString = child_process.execSync(command).toString().trim(); return parseFloat(durationString); }; /** Return the number of audio tracks */ export const getNumberOfAudioTracks = (file: string) => { - const command = `"${ffprobe.path}" -v error -show_entries stream=index -select_streams a -of json "${file}"`; + const command = `"${ffprobePath}" -v error -show_entries stream=index -select_streams a -of json "${file}"`; const result = child_process.execSync(command, { encoding: "utf8" }); return JSON.parse(result).streams.length; };