Skip to content

Commit

Permalink
feat: change pushLive to upStreaming
Browse files Browse the repository at this point in the history
  • Loading branch information
drawcall committed Sep 23, 2021
1 parent 381aa14 commit 0064602
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/live.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const createFFTask = () => {
log: true,
preset: 'veryfast',
vprofile: 'baseline',
pushLive: true,
upStreaming: true,
audio,
});

Expand Down
2 changes: 1 addition & 1 deletion lib/conf/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Conf {
this.copyByDefaultVal(conf, 'vprofile', 'main');
this.copyByDefaultVal(conf, 'debug', false);
this.copyByDefaultVal(conf, 'audioLoop', true);
this.copyByDefaultVal(conf, 'pushLive', false);
this.copyByDefaultVal(conf, 'upStreaming', false);
this.copyByDefaultVal(conf, 'cacheFormat', 'mp4');
this.copyByDefaultVal(conf, 'hasTransition', false);
this.copyByDefaultVal(conf, 'defaultOutputOptions', true);
Expand Down
4 changes: 2 additions & 2 deletions lib/core/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ class Renderer extends FFBase {
start() {
const { creator } = this;
const log = creator.getConf('log');
const pushLive = creator.getConf('pushLive');
const upStreaming = creator.getConf('upStreaming');

Perf.setEnabled(log);
Perf.start();

const { scenes } = creator;
if (ScenesUtil.isSingle(creator) || pushLive) {
if (ScenesUtil.isSingle(creator) || upStreaming) {
const scene = scenes[0];
scene.addAudio();
this.singleStart(scene);
Expand Down
4 changes: 2 additions & 2 deletions lib/core/synthesis.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class Synthesis extends FFBase {
*/
start() {
const { creator, conf } = this;
const pushLive = conf.getVal('pushLive');
const upStreaming = conf.getVal('upStreaming');

if (pushLive) {
if (upStreaming) {
this.liveOutput();
} else if (ScenesUtil.isSingle(creator)) {
this.mvOutput();
Expand Down
4 changes: 2 additions & 2 deletions lib/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ class FFCreator extends FFCon {
* @public
*/
generateOutput() {
const pushLive = this.getConf('pushLive');
const upStreaming = this.getConf('upStreaming');
let outputDir = this.getConf('outputDir');

if (this.inCenter && outputDir && !pushLive) {
if (this.inCenter && outputDir && !upStreaming) {
outputDir = outputDir.replace(/\/$/, '');
const output = `${outputDir}/${Utils.uid()}.mp4`;
this.setConf('output', output);
Expand Down
12 changes: 6 additions & 6 deletions lib/node/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ class FFScene extends FFCon {
createNewCommand() {
const conf = this.rootConf();
const threads = conf.getVal('threads');
const pushLive = conf.getVal('pushLive');
const upStreaming = conf.getVal('upStreaming');
const command = FFmpegUtil.createCommand({ threads });
if (!pushLive) {
if (!upStreaming) {
command.setDuration(this.duration);
}

Expand All @@ -138,9 +138,9 @@ class FFScene extends FFCon {

addCommandOptions(command) {
const conf = this.rootConf();
const pushLive = conf.getVal('pushLive');
const upStreaming = conf.getVal('upStreaming');

if (pushLive) {
if (upStreaming) {
FFmpegUtil.addDefaultOptions({ command, conf, audio: true });
} else {
FFmpegUtil.addDefaultOptions({ command, conf, audio: false });
Expand All @@ -157,9 +157,9 @@ class FFScene extends FFCon {
let filepath;
const conf = this.rootConf();
const output = conf.getVal('output');
const pushLive = conf.getVal('pushLive');
const upStreaming = conf.getVal('upStreaming');

if (pushLive) {
if (upStreaming) {
filepath = output;
command.outputOptions(['-f', 'flv']);
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const FFmpegUtil = {
const crf = conf.getVal('crf');
const preset = conf.getVal('preset');
const vprofile = conf.getVal('vprofile');
const pushLive = conf.getVal('pushLive');
const upStreaming = conf.getVal('upStreaming');

let outputOptions = []
//---- misc ----
Expand Down Expand Up @@ -118,7 +118,7 @@ const FFmpegUtil = {
}

//---- live stream ----
if (!pushLive) {
if (!upStreaming) {
outputOptions = outputOptions.concat(['-map', '0']);
}

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

0 comments on commit 0064602

Please sign in to comment.