mifi / editly

Slick, declarative command line video editing & API
MIT License
4.64k stars 295 forks source link

Get Progress of Editly #196

Open liamcharmer opened 2 years ago

liamcharmer commented 2 years ago

Is there a simple way to get the progress of the editly running?

mifi commented 2 years ago

unfortunately not, but it should be possible to implement some onProgress function

atulmy commented 2 years ago

That would be quite useful to show end user percentage completion of rendering a video.

twicer-is-coder commented 1 year ago

Really need the on-progress event.

wisekaa03 commented 1 year ago

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);
            },
          );
        });
...
twicer-is-coder commented 1 year ago

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.

SaadBazaz commented 1 year ago

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.