Skip to content

Commit

Permalink
feat: add conf crf and preset
Browse files Browse the repository at this point in the history
feat: add conf crf and preset
  • Loading branch information
drawcall committed Dec 18, 2020
1 parent 2faa7a4 commit e9fe07c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/conf/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 12 additions & 3 deletions lib/core/synthesis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand All @@ -144,6 +148,11 @@ class Synthesis extends EventEmitter {
fps,
]);

//---- vb -----
if (vb) {
opts = opts.concat(['-vb', vb]);
}

return opts;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit e9fe07c

Please sign in to comment.