fixed [settings always new in cwd]
This commit is contained in:
parent
55c12e920a
commit
894228d189
3 changed files with 149 additions and 190 deletions
12
bin/index.js
12
bin/index.js
|
@ -7,16 +7,16 @@ import path from "path"
|
||||||
//get settings
|
//get settings
|
||||||
let settings = new SettingsManager()
|
let settings = new SettingsManager()
|
||||||
await settings.start()
|
await settings.start()
|
||||||
let resolve = path.resolve
|
|
||||||
let term = termkit.terminal
|
let term = termkit.terminal
|
||||||
const ui = new UI(settings.settings, settings.currentSetting)
|
const ui = new UI(settings.settings, settings.currentSetting)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO : Adapt audio quality as well to accomodate long videos(Currently 5m is too much)
|
* TODO : FIND A WAY TO COMPILE THIS:..
|
||||||
* FIND A WAY TO COMPILE THIS:..
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const inputList = process.argv//.slice()
|
const inputList = process.argv.slice(2)
|
||||||
//if launched without params
|
//if launched without params
|
||||||
if (!inputList[0]) {
|
if (!inputList[0]) {
|
||||||
ui.startMenu() //stops program here
|
ui.startMenu() //stops program here
|
||||||
|
@ -32,7 +32,7 @@ if (inputList[0] == "-preset") {
|
||||||
|
|
||||||
for (let i = 2; i < inputList.length; i++) {
|
for (let i = 2; i < inputList.length; i++) {
|
||||||
let file
|
let file
|
||||||
file = resolve(inputList[i])
|
file = path.resolve(inputList[i])
|
||||||
|
|
||||||
filePaths.push(file)
|
filePaths.push(file)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ if (inputList[0] == "-preset") {
|
||||||
else {
|
else {
|
||||||
for (let i = 0; i < inputList.length; i++) {
|
for (let i = 0; i < inputList.length; i++) {
|
||||||
let file
|
let file
|
||||||
file = resolve(inputList[i])
|
file = path.resolve(inputList[i])
|
||||||
|
|
||||||
filePaths.push(file)
|
filePaths.push(file)
|
||||||
|
|
||||||
|
|
|
@ -76,9 +76,9 @@ export class Encoder {
|
||||||
command += `ffmpeg -y -i "${path}" -vcodec libvpx-vp9 -acodec libvorbis `
|
command += `ffmpeg -y -i "${path}" -vcodec libvpx-vp9 -acodec libvorbis `
|
||||||
command += `-deadline ${this.currentSetting.deadline} `
|
command += `-deadline ${this.currentSetting.deadline} `
|
||||||
command += `-cpu-used ${this.currentSetting.cpuUsed} `
|
command += `-cpu-used ${this.currentSetting.cpuUsed} `
|
||||||
if (this.currentSetting?.minrate) {
|
if (this.currentSetting?.bitrateError) {
|
||||||
command += `-b:v ${Math.round(videoBitRate * 0.95)}k `
|
command += `-b:v ${Math.round(videoBitRate / 100 * this.currentSetting.bitrateError)}k `
|
||||||
command += `-minrate ${Math.round(videoBitRate / 100 * this.currentSetting.minrate)}k `
|
command += `-minrate ${Math.round(videoBitRate)}k `
|
||||||
command += `-maxrate ${videoBitRate}k `
|
command += `-maxrate ${videoBitRate}k `
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
|
import path from "path"
|
||||||
export class SettingsManager {
|
export class SettingsManager {
|
||||||
|
|
||||||
settings
|
settings
|
||||||
|
@ -14,8 +14,8 @@ export class SettingsManager {
|
||||||
|
|
||||||
|
|
||||||
async #init() {
|
async #init() {
|
||||||
|
let settings
|
||||||
let settings = await this.#getSettings().catch(async (err) => {
|
settings = await this.#getSettings().catch(async (err) => {
|
||||||
settings = undefined
|
settings = undefined
|
||||||
})
|
})
|
||||||
//console.log(settings)
|
//console.log(settings)
|
||||||
|
@ -25,7 +25,7 @@ export class SettingsManager {
|
||||||
}
|
}
|
||||||
async #getSettings() {
|
async #getSettings() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const getSettings = fs.readFile("settings.json", (err, data) => {
|
const getSettings = fs.readFile(path.resolve(__dirname, "settings.json"), (err, data) => {
|
||||||
if (err) reject(err)
|
if (err) reject(err)
|
||||||
resolve(data)
|
resolve(data)
|
||||||
})
|
})
|
||||||
|
@ -34,184 +34,143 @@ export class SettingsManager {
|
||||||
async #makeNewSettingsFile() {
|
async #makeNewSettingsFile() {
|
||||||
const settings = `
|
const settings = `
|
||||||
{
|
{
|
||||||
"currentSetting": 2,
|
"currentSetting": 3,
|
||||||
"presets": [{
|
"presets": [{
|
||||||
"name": "Most efficient 8 megabytes of your life",
|
"name": "Most efficient 8 megabytes of your life",
|
||||||
"cpuUsed": 0,
|
"cpuUsed": 0,
|
||||||
"deadline": "best",
|
"deadline": "best",
|
||||||
"minrate": 90,
|
"bitrateError": 90,
|
||||||
"crfMap": [{
|
"crfMap": [{
|
||||||
"resolution": 240,
|
"resolution": 240,
|
||||||
"crf": 1
|
"crf": 1
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 360,
|
"resolution": 360,
|
||||||
"crf": 1
|
"crf": 1
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 480,
|
"resolution": 480,
|
||||||
"crf": 1
|
"crf": 1
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 720,
|
"resolution": 720,
|
||||||
"crf": 1
|
"crf": 1
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1080,
|
"resolution": 1080,
|
||||||
"crf": 1
|
"crf": 1
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1440,
|
"resolution": 1440,
|
||||||
"crf": 1
|
"crf": 1
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 2160,
|
"resolution": 2160,
|
||||||
"crf": 1
|
"crf": 1
|
||||||
}
|
}]
|
||||||
]
|
}, {
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "I have some time to kill",
|
"name": "I have some time to kill",
|
||||||
"cpuUsed": 1,
|
"cpuUsed": 1,
|
||||||
"deadline": "good",
|
"deadline": "good",
|
||||||
"minrate": 75,
|
"bitrateError": 90,
|
||||||
"crfMap": [{
|
"crfMap": [{
|
||||||
"resolution": 240,
|
"resolution": 240,
|
||||||
"crf": 20
|
"crf": 20
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 360,
|
"resolution": 360,
|
||||||
"crf": 20
|
"crf": 20
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 480,
|
"resolution": 480,
|
||||||
"crf": 20
|
"crf": 20
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 720,
|
"resolution": 720,
|
||||||
"crf": 20
|
"crf": 20
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1080,
|
"resolution": 1080,
|
||||||
"crf": 17
|
"crf": 17
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1440,
|
"resolution": 1440,
|
||||||
"crf": 15
|
"crf": 15
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 2160,
|
"resolution": 2160,
|
||||||
"crf": 10
|
"crf": 10
|
||||||
}
|
}]
|
||||||
]
|
}, {
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Mid",
|
"name": "Mid",
|
||||||
"cpuUsed": 3,
|
"cpuUsed": 3,
|
||||||
"deadline": "good",
|
"deadline": "good",
|
||||||
"minrate":75,
|
"bitrateError": 80,
|
||||||
"crfMap": [{
|
"crfMap": [{
|
||||||
"resolution": 240,
|
"resolution": 240,
|
||||||
"crf": 30
|
"crf": 30
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 360,
|
"resolution": 360,
|
||||||
"crf": 30
|
"crf": 30
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 480,
|
"resolution": 480,
|
||||||
"crf": 30
|
"crf": 30
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 720,
|
"resolution": 720,
|
||||||
"crf": 25
|
"crf": 25
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1080,
|
"resolution": 1080,
|
||||||
"crf": 20
|
"crf": 20
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1440,
|
"resolution": 1440,
|
||||||
"crf": 15
|
"crf": 15
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 2160,
|
"resolution": 2160,
|
||||||
"crf": 10
|
"crf": 10
|
||||||
}
|
}]
|
||||||
]
|
}, {
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "I don't like waiting",
|
"name": "I don't like waiting",
|
||||||
"cpuUsed": 4,
|
"cpuUsed": 4,
|
||||||
"deadline": 100,
|
"deadline": 100,
|
||||||
"minrate": 90,
|
"bitrateError": 70,
|
||||||
"crfMap": [{
|
"crfMap": [{
|
||||||
"resolution": 240,
|
"resolution": 240,
|
||||||
"crf": 45
|
"crf": 45
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 360,
|
"resolution": 360,
|
||||||
"crf": 42
|
"crf": 42
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 480,
|
"resolution": 480,
|
||||||
"crf": 40
|
"crf": 40
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 720,
|
"resolution": 720,
|
||||||
"crf": 35
|
"crf": 35
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1080,
|
"resolution": 1080,
|
||||||
"crf": 30
|
"crf": 30
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1440,
|
"resolution": 1440,
|
||||||
"crf": 25
|
"crf": 25
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 2160,
|
"resolution": 2160,
|
||||||
"crf": 20
|
"crf": 20
|
||||||
}
|
}]
|
||||||
]
|
}, {
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "I want it, NOW!",
|
"name": "I want it, NOW!",
|
||||||
"cpuUsed": 4,
|
"cpuUsed": 4,
|
||||||
"deadline": "realtime",
|
"deadline": "realtime",
|
||||||
"minrate": 50,
|
"bitrateError": 60,
|
||||||
"crfMap": [{
|
"crfMap": [{
|
||||||
"resolution": 240,
|
"resolution": 240,
|
||||||
"crf": 40
|
"crf": 40
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 360,
|
"resolution": 360,
|
||||||
"crf": 35
|
"crf": 35
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 480,
|
"resolution": 480,
|
||||||
"crf": 30
|
"crf": 30
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 720,
|
"resolution": 720,
|
||||||
"crf": 25
|
"crf": 25
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1080,
|
"resolution": 1080,
|
||||||
"crf": 20
|
"crf": 20
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 1440,
|
"resolution": 1440,
|
||||||
"crf": 15
|
"crf": 15
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
"resolution": 2160,
|
"resolution": 2160,
|
||||||
"crf": 10
|
"crf": 10
|
||||||
}
|
}]
|
||||||
]
|
}]
|
||||||
}
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
Loading…
Reference in a new issue