Open liamcharmer opened 2 years ago
unfortunately not, but it should be possible to implement some onProgress function
That would be quite useful to show end user percentage completion of rendering a video.
Really need the on-progress event.
Also possible:
...
const outPath = await new Promise<string | Error>((resolve, reject) => {
const childEditly = child.fork(
'node_modules/.bin/editly',
['--json', editlyPath],
{
silent: true,
},
);
childEditly.stdout?.on('data', (message: Buffer) => {
const msg = message.toString();
this.logger.debug(
`Editly on '${renderEditor.id}' / '${renderEditor.name}': ${msg}`,
'Editly',
);
const percent = msg.match(/(\d+%)/g);
if (Array.isArray(percent) && percent.length > 0) {
this.editorRepository
.update(renderEditor.id, {
renderingPercent: parseInt(percent[percent.length - 1], 10),
})
.catch((error: any) => {
this.logger.error(error?.message, error?.stack, 'Editly');
});
}
});
childEditly.stderr?.on('data', (message: Buffer) => {
const msg = message.toString();
this.logger.debug(msg, undefined, 'Editly');
});
childEditly.on('error', (error: Error) => {
this.logger.error(error.message, error.stack, 'Editly');
reject(error);
});
childEditly.on(
'exit',
(/* code: number | null, signal: NodeJS.Signals | null */) => {
resolve(editlyConfig.outPath);
},
);
});
...
renderEditor
Maybe wrap into a proper function like passing JSON object etc. Just make a wrapper function for it. It will help others a lot. With this approach, you can use the event emitter as well when creating a wrapper.
ffmpeg shows how many frames have been rendered in stdout. ffmpeg-probes tells how many frames the video contains.
So a simple ratio of them can be the progress.
Is there a simple way to get the progress of the editly running?