SamuelScheit / puppeteer-stream

A Library for puppeteer to retrieve audio and/or video streams
MIT License
333 stars 105 forks source link

BUG report: video freezes after one click on page. #106

Closed MostajeranMohammad closed 1 year ago

MostajeranMohammad commented 1 year ago

Hi. I'm trying to build an app with this library but after click on play sound button picture freezes. here's my code: `import { launch, getStream } from 'puppeteer-stream'; import { createWriteStream } from 'fs';

const file = createWriteStream(__dirname + '/../recordings' + '/test.webm');

async function main() { const browser = await launch({ executablePath: '/usr/bin/google-chrome', headless: false, defaultViewport: null, devtools: false, args: [ '--window-size=1920,1080', '--window-position=1921,0', '--autoplay-policy=no-user-gesture-required', ], ignoreDefaultArgs: ['--mute-audio'], });

const page = await browser.newPage(); page.setViewport({ width: 1920, height: 1080, deviceScaleFactor: 1, isLandscape: true, }); await page.goto('https://www.rainymood.com/', { timeout: 0 }); const stream = await getStream(page, { audio: true, video: true, mimeType: 'video/webm;codecs=vp8,opus', }); stream.pipe(file); console.log('recording');

console.log('now clicking...');

const button = await page.waitForSelector('#pButton'); await button.click();

setTimeout(async () => { await stream.destroy(); file.end(); file.close(() => { process.exit(0); }); console.log('finished'); }, 1000 * 40); }

main(); `

MostajeranMohammad commented 1 year ago

oh this is because of my player bug. when i played it's output with chrome doesn't freeze. maybe this problem raised because of output file doesn't have correct duration. i must convert it to mp4 with ffmpeg.