Skip to content

Commit

Permalink
Create toolsPath and download ffmpeg to it (#111)
Browse files Browse the repository at this point in the history
AppImage mount path is readonly, cant download files to it
  • Loading branch information
IRHM authored Mar 14, 2021
1 parent 621acea commit 38dc623
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/libs/helpers/pathHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export default class PathHelper {
return Path.join(os.homedir(), "Documents", "Casterr");
}

public static get toolsPath() {
return Path.join(this.mainFolderPath, "Tools");
}

public static get homeFolderPath() {
return os.homedir();
}
Expand Down
9 changes: 5 additions & 4 deletions src/libs/recorder/ffmpeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as fs from "fs";
import * as childProcess from "child_process";
import Downloader from "./../helpers/downloader";
import Notifications from "./../helpers/notifications";
import PathHelper from "../helpers/pathHelper";

export default class FFmpeg {
constructor(private which: "ffmpeg" | "ffprobe" = "ffmpeg") {}
Expand Down Expand Up @@ -96,9 +97,9 @@ export default class FFmpeg {
* If FFmpeg/probe doesn't exist, download it first then return its path.
*/
public async getPath() {
const execPath = path.dirname(process.execPath);
const ffmpegPath = path.join(execPath, FFmpeg.ffmpegExeName);
const ffprobePath = path.join(execPath, FFmpeg.ffprobeExeName);
const ffDir = PathHelper.ensureExists(PathHelper.toolsPath, true);
const ffmpegPath = path.join(ffDir, FFmpeg.ffmpegExeName);
const ffprobePath = path.join(ffDir, FFmpeg.ffprobeExeName);

// If ffmpeg or ffprobe does not exist, go download it
if (!fs.existsSync(ffmpegPath) || !fs.existsSync(ffprobePath)) {
Expand All @@ -124,7 +125,7 @@ export default class FFmpeg {
Notifications.popup("ffmpegDownloadProgress", "Extracting Recording Utilities", undefined);

// Extract zip
await Downloader.extract(downloadTo, execPath, [FFmpeg.ffmpegExeName, FFmpeg.ffprobeExeName]);
await Downloader.extract(downloadTo, ffDir, [FFmpeg.ffmpegExeName, FFmpeg.ffprobeExeName]);

// Delete popup
Notifications.deletePopup("ffmpegDownloadProgress");
Expand Down

0 comments on commit 38dc623

Please sign in to comment.