Closed sagarrajput closed 1 year ago
I'm trying to run below code, it runs however returns 0 bytes szie file test_recording.webm @SamuelScheit
const { executablePath } = require('puppeteer') const fs = require("fs"); const { exec } = require("child_process"); const file = fs.createWriteStream(__dirname + "/test_recording.webm"); async function test() { const browser = await launch({ executablePath: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome', defaultViewport: { width: 1920, height: 1080, }, }); const page = await browser.newPage(); await page.goto("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); const stream = await getStream(page, { audio: true, video: true, frameSize: 1000 }); console.log("recording"); // this will pipe the stream to ffmpeg and convert the webm to mp4 format const ffmpeg = exec('ffmpeg -y -i - output.mp4'); ffmpeg.stderr.on("data", (chunk) => { console.log(chunk.toString()); }); stream.pipe(ffmpeg.stdin); setTimeout(async () => { await stream.destroy(); ffmpeg.kill("SIGINT"); console.log("finished"); }, 1000 * 10); } test();
You are streaming to ffmpeg file output.mp4 instead of test_recording.webm
output.mp4
test_recording.webm
I'm trying to run below code, it runs however returns 0 bytes szie file test_recording.webm @SamuelScheit