split into another file

This commit is contained in:
Mylloon 2023-08-01 09:34:41 +02:00
parent 5f7370830d
commit ff75f7ce08
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 18 additions and 15 deletions

View file

@ -1,8 +1,8 @@
import { BrowserWindow, app, dialog, ipcMain } from "electron";
import { unlink, statSync } from "fs";
import { statSync, unlink } from "fs";
import { getNewFilename, getVideoDuration } from "./utils/misc";
import path = require("path");
import ffmpegPath = require("ffmpeg-static");
import ffprobe = require("ffprobe-static");
import child_process = require("child_process");
const moviesFilter = {
@ -28,19 +28,6 @@ const createWindow = () => {
return win;
};
/* Create a new filename from the OG one */
const getNewFilename = (ogFile: string, part: string) => {
const oldFile = path.parse(ogFile);
return path.join(oldFile.dir, `${part}`.concat(oldFile.base));
};
/** Return the duration of a video in second */
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();
return parseFloat(durationString);
};
/** Merge all audios track of a video into one */
const mergeAudio = (file: string) => {
const tmp_file = getNewFilename(file, "TMP_");

16
src/utils/misc.ts Normal file
View file

@ -0,0 +1,16 @@
import ffprobe = require("ffprobe-static");
import child_process = require("child_process");
import path = require("path");
/* Create a new filename from the OG one */
export const getNewFilename = (ogFile: string, part: string) => {
const oldFile = path.parse(ogFile);
return path.join(oldFile.dir, `${part}`.concat(oldFile.base));
};
/** 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();
return parseFloat(durationString);
};