From e9fe07c5011e8783543d727e743a5c3acc3d4dde Mon Sep 17 00:00:00 2001 From: drawcall Date: Fri, 18 Dec 2020 18:10:43 +0800 Subject: [PATCH] feat: add conf crf and preset feat: add conf crf and preset --- lib/conf/conf.js | 3 +++ lib/core/synthesis.js | 15 ++++++++++++--- package.json | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/conf/conf.js b/lib/conf/conf.js index daa45950..079b8f21 100755 --- a/lib/conf/conf.js +++ b/lib/conf/conf.js @@ -20,6 +20,9 @@ class Conf { this.conf = conf; this.conf.pathId = Utils.uid(); + this.copyByDefaultVal(conf, 'crf', 20); + this.copyByDefaultVal(conf, 'vb', null); + this.copyByDefaultVal(conf, 'preset', 'medium'); this.copyByDefaultVal(conf, 'debug', false); this.copyByDefaultVal(conf, 'audioLoop', true); this.copyByDefaultVal(conf, 'defaultOutputOptions', true); diff --git a/lib/core/synthesis.js b/lib/core/synthesis.js index 30d9f910..4dd80cb5 100755 --- a/lib/core/synthesis.js +++ b/lib/core/synthesis.js @@ -115,8 +115,12 @@ class Synthesis extends EventEmitter { */ getDefaultOutputOptions() { const {conf} = this; + const vb = conf.getVal('vb'); const fps = conf.getVal('fps'); - const opts = [] + const crf = conf.getVal('crf'); + const preset = conf.getVal('preset'); + + let opts = [] // misc .concat([ '-hide_banner', // hide_banner - parameter, you can display only meta information @@ -133,9 +137,9 @@ class Synthesis extends EventEmitter { '-profile:v', 'main', // profile:v - main profile: mainstream image quality. Provide I / P / B frames '-preset', - 'medium', // preset - compromised encoding speed + preset, // preset - compromised encoding speed '-crf', - '20', // crf - The range of quantization ratio is 0 ~ 51, where 0 is lossless mode, 23 is the default value, 51 may be the worst + crf, // crf - The range of quantization ratio is 0 ~ 51, where 0 is lossless mode, 23 is the default value, 51 may be the worst '-movflags', 'faststart', '-pix_fmt', @@ -144,6 +148,11 @@ class Synthesis extends EventEmitter { fps, ]); + //---- vb ----- + if (vb) { + opts = opts.concat(['-vb', vb]); + } + return opts; } diff --git a/package.json b/package.json index dd46fcc9..6aa4ea7f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ffcreator", - "version": "1.3.9", + "version": "1.3.10", "description": "FFCreator is a lightweight and flexible short video production library", "main": "lib/index.js", "scripts": {