-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclip-2-min.js
39 lines (34 loc) · 987 Bytes
/
clip-2-min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const path = require('path')
require('dotenv').config({
path: path.resolve(__dirname, '.env')
})
const exec = require('child_process').execSync
const delay = require('delay')
const {
INPUT_FILE,
OUTPUT_FILE,
MKV_FOLDER,
TIMESTAMP_FORMAT,
FFMPEG_PATH,
FFPROBE_PATH,
} = process.env
const inputFile = INPUT_FILE || ''
const outputFile = OUTPUT_FILE || ''
const folder = MKV_FOLDER || ''
const timeFormat = TIMESTAMP_FORMAT || ''
const ffmpegPath = FFMPEG_PATH || ''
const ffprobePath = FFPROBE_PATH || ''
// #node index.js -s 30 -i "$inputFile" -o "$outputFile"
const indexPath = path.resolve(__dirname, 'index.js')
const command = `node ${indexPath} -s 120 -f "${folder}" -t "${timeFormat}" -x "${ffmpegPath}" -c "${ffprobePath}"`
console.log(command)
Promise.resolve().then(async () => {
try {
exec(command, {stdio: 'inherit'})
} catch (err) {
if (err) {
console.error(err)
await delay(3000)
}
}
})