Streampunk / beamcoder

Node.js native bindings to FFmpeg.
GNU General Public License v3.0
399 stars 76 forks source link

Encoder message error catching #107

Closed piercus closed 1 year ago

piercus commented 2 years ago

Hello,

Thanks for this great library.

I was wondering if it would be possible to catch the errors given. When i'm setting up the parameters wronlgly, for the encoder, i'm often having important/interesting messages like

[mpeg2video @ 0x7fc8c00ba500] The encoder timebase is not set.

Next time when the system is logging

[NULL @ 0x7fc8c00ba500] No codec provided to avcodec_open2()

I see the message in the console, but i was wondering if there is any way to catch this message.

The only thing i could detect programmatically is an empty {packets: []}

Do you have any idea of how to detect/catch this kind of error from the code, instead of relying on the stdout/stderr.

Would it be technically feasible to add an event .on('error', err => {}) or .on('message', msg => {}) in the encoder ?

piercus commented 2 years ago

After seeing av_log_set_callback

It should be possible to add something like beamcoder.setLoggingCallback((message, level) => {})