refactor import

This commit is contained in:
Abhinav 2022-11-14 19:27:47 +05:30
parent 3895ad9ded
commit 19a3c38bf1

View file

@ -2,12 +2,13 @@ import pathToFfmpeg from 'ffmpeg-static';
import path from 'path'; import path from 'path';
const shellescape = require('any-shell-escape'); const shellescape = require('any-shell-escape');
import util from 'util'; import util from 'util';
const exec = util.promisify(require('child_process').exec);
import log from 'electron-log'; import log from 'electron-log';
import { readFile, rmSync } from 'promise-fs'; import { readFile, rmSync } from 'promise-fs';
import { logErrorSentry } from './sentry'; import { logErrorSentry } from './sentry';
import { generateTempName, getTempDirPath } from '../utils/temp'; import { generateTempName, getTempDirPath } from '../utils/temp';
const execAsync = util.promisify(require('child_process').exec);
export const INPUT_PATH_PLACEHOLDER = 'INPUT'; export const INPUT_PATH_PLACEHOLDER = 'INPUT';
export const FFMPEG_PLACEHOLDER = 'FFMPEG'; export const FFMPEG_PLACEHOLDER = 'FFMPEG';
export const OUTPUT_PATH_PLACEHOLDER = 'OUTPUT'; export const OUTPUT_PATH_PLACEHOLDER = 'OUTPUT';
@ -43,7 +44,7 @@ export async function runFFmpegCmd(
}); });
cmd = shellescape(cmd); cmd = shellescape(cmd);
log.info('cmd', cmd); log.info('cmd', cmd);
await exec(cmd); await execAsync(cmd);
return new Uint8Array(await readFile(tempOutputFilePath)); return new Uint8Array(await readFile(tempOutputFilePath));
} catch (e) { } catch (e) {
logErrorSentry(e, 'ffmpeg run command error'); logErrorSentry(e, 'ffmpeg run command error');