qawolf / playwright-video

🎬 Save a video of a Playwright page
BSD 3-Clause "New" or "Revised" License
194 stars 17 forks source link

Pass ffmpeg’s stdout and stderr to ffmpegerror event #141

Open dtinth opened 3 years ago

dtinth commented 3 years ago

https://github.com/qawolf/playwright-video/blob/58037692bfbd30c9e1a1a2b011488e1149400499/src/VideoWriter.ts#L48-L61

fluent-ffmpeg sends the stdout and stderr, so our error handler can accept this:

-        .on('error', (e) => {
+        .on('error', (e, stdout, stderr) => {

This helps with some obscure edge cases like this:

[libx264 @ 0x648b540] width not divisible by 2 (1045x730)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

The first line which shows the culprit isn’t present in any output generated by playwright-video and DEBUG='pw-video:*'. I had to dig in and make it print the stderr so I can see the real reason.