split into another file
This commit is contained in:
parent
5f7370830d
commit
ff75f7ce08
2 changed files with 18 additions and 15 deletions
17
src/main.ts
17
src/main.ts
|
@ -1,8 +1,8 @@
|
||||||
import { BrowserWindow, app, dialog, ipcMain } from "electron";
|
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 path = require("path");
|
||||||
import ffmpegPath = require("ffmpeg-static");
|
import ffmpegPath = require("ffmpeg-static");
|
||||||
import ffprobe = require("ffprobe-static");
|
|
||||||
import child_process = require("child_process");
|
import child_process = require("child_process");
|
||||||
|
|
||||||
const moviesFilter = {
|
const moviesFilter = {
|
||||||
|
@ -28,19 +28,6 @@ const createWindow = () => {
|
||||||
return win;
|
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 */
|
/** Merge all audios track of a video into one */
|
||||||
const mergeAudio = (file: string) => {
|
const mergeAudio = (file: string) => {
|
||||||
const tmp_file = getNewFilename(file, "TMP_");
|
const tmp_file = getNewFilename(file, "TMP_");
|
||||||
|
|
16
src/utils/misc.ts
Normal file
16
src/utils/misc.ts
Normal 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);
|
||||||
|
};
|
Loading…
Reference in a new issue