Skip to content

Commit

Permalink
feat: add ff format cache
Browse files Browse the repository at this point in the history
  • Loading branch information
drawcall committed May 10, 2021
1 parent 3a93202 commit 8919401
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
3 changes: 2 additions & 1 deletion examples/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ const createFFTask = () => {
const width = (576 * Math.random()) >> 0;
const height = (1024 * Math.random()) >> 0;

console.log('wxh', width, height);
const creator = new FFCreator({
cacheDir,
outputDir,
width,
height,
debug: true,
cacheType: 'jpg',
cacheType: 'raw',
cacheQuality: 70,
cacheClarity: 80,
audio,
Expand Down
3 changes: 3 additions & 0 deletions lib/core/synthesis.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ class Synthesis extends EventEmitter {
*/
addInput() {
const { conf } = this;
const type = conf.getVal('cacheType');
const dir = conf.getVal('detailedCacheDir');

const files = FS.getCacheFilePath(dir);
this.command.addInput(files);
if (type !== 'raw') this.command.inputFormat('image2');
}

/**
Expand Down
22 changes: 11 additions & 11 deletions lib/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ class FFCreator extends FFCon {
* @private
*/
createAppScene() {
let width = this.getConf('width');
let height = this.getConf('height');
width = Utils.courtship(width);
height = Utils.courtship(height);
this.resetSize();
const width = this.getConf('width');
const height = this.getConf('height');

this.display = Pool.get('scene', () => new Scene({ width, height }));
this.display.width = width;
Expand Down Expand Up @@ -163,13 +162,14 @@ class FFCreator extends FFCon {
* @param {number} height - stage height
* @public
*/
setSize(width, height) {
width = Utils.courtship(width);
height = Utils.courtship(height);
this.setConf('width', width);
this.setConf('height', height);
this.display.width = width;
this.display.height = height;
resetSize(width, height) {
if (!width) {
width = this.getConf('width');
height = this.getConf('height');
}

this.setConf('width', Utils.courtship(width));
this.setConf('height', Utils.courtship(height));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const FS = {
},

setCacheFormat(format) {
currFormat = format;
currFormat = format === 'raw' ? format : 'ff';
},

/**
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": "2.0.7",
"version": "2.0.8",
"description": "FFCreator is a lightweight and flexible short video production library",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 8919401

Please sign in to comment.