You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm submitting a ...
[x ] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project
Summary
I have a current CLI tool, which takes a url. It will then slowly scroll while screen recording. The issue is that I have a scroll duration longer than 2 minutes I get a Error processing URLs: ProtocolError: Runtime.callFunctionOn timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed. Error. Just wondering what could be the reason. Could possibly be an async issue? I am setting the time in my autoscroll function
Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
Entire Error Log
C:\Users\USER\Desktop\exampleSubreddit>auto-scroll-record https://www.reddit.com/r/exampleSubreddit
Processing URLs: [ 'https://www.reddit.com/r/exampleSubreddit' ]
Error processing URLs: ProtocolError: Runtime.callFunctionOn timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
at <instance_members_initializer> (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\common\CallbackRegistry.js:93:14)
at new Callback (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\common\CallbackRegistry.js:97:16)
at CallbackRegistry.create (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\common\CallbackRegistry.js:22:26)
at Connection._rawSend (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\Connection.js:80:26)
at CdpCDPSession.send (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\CDPSession.js:66:33)
at #evaluate (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:202:50)
at ExecutionContext.evaluate (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:117:36)
at IsolatedWorld.evaluate (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\IsolatedWorld.js:124:30)
at CdpFrame.evaluate (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\api\Frame.js:343:43)
at CdpFrame.<anonymous> (C:\Users\USER\Programming\Projects\Node\auto-scroll-record\node_modules\puppeteer-core\lib\cjs\puppeteer\util\decorators.js:98:27)
Entire script
const puppeteer = require('puppeteer');
const { PuppeteerScreenRecorder } = require('puppeteer-screen-recorder');
const fs = require('fs');
const path = require('path');
const Config = {
followNewTab: true,
fps: 60, // Increased to 60 for smoother motion
ffmpeg_Path: null, // Default: let the library handle FFmpeg
videoFrame: {
width: 1920,
height: 1080, // 16:9 aspect ratio at 1080p
},
videoCrf: 15, // Lowered for higher quality, where lower means better (default is 23-18)
videoCodec: 'libx264',
videoPreset: 'slow', // Using 'slow' for better compression efficiency at the cost of encoding speed
videoBitrate: '8000k', // Increased bitrate for better quality
autopad: false, // Disabled autopad
};
async function processUrls(urls) {
console.log('Processing URLs:', urls);
const browser = await puppeteer.launch({
headless: false,
timeout: 0, // Setting timeout to 0 disables the timeout
defaultViewport: null, // Setting defaultViewport to null allows dynamic viewport
});
const videosDir = path.join(process.cwd(), 'videos');
if (!fs.existsSync(videosDir)){
fs.mkdirSync(videosDir, { recursive: true });
}
for (let url of urls) {
const page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 }); // Ensure viewport matches recording resolution
const recorder = new PuppeteerScreenRecorder(page, Config);
const safeTitle = url.replace(/[^a-zA-Z]/g, "").slice(0, 10); // Keeping filenames short and safe
const fileName = `${safeTitle}_${new Date().getTime()}.mp4`; // Unique filename for each recording
const savePath = path.join(videosDir, fileName);
await recorder.start(savePath);
await page.goto(url, { waitUntil: 'networkidle2' });
await autoScroll(page);
await recorder.stop();
await page.close();
}
await browser.close();
console.log('Finished processing URLs.');
}
async function autoScroll(page) {
await page.evaluate(() => {
return new Promise((resolve) => {
const totalTime = 180000; // 2 minutes in milliseconds
const stepTime = 100; // time between steps in milliseconds
// Define the smooth scroll function
let lastTimestamp = performance.now();
function smoothScroll() {
const timestamp = performance.now();
const progress = timestamp - lastTimestamp;
// Calculate the distance to scroll based on the progress
const distance = progress * 0.1; // Adjust speed here
window.scrollBy(0, distance);
lastTimestamp = timestamp;
if (lastTimestamp - startTime < totalTime) {
requestAnimationFrame(smoothScroll);
} else {
resolve();
}
}
const startTime = performance.now();
requestAnimationFrame(smoothScroll);
});
});
}
module.exports = { processUrls };
The text was updated successfully, but these errors were encountered:
I'm submitting a ...
[x ] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project
Summary
I have a current CLI tool, which takes a url. It will then slowly scroll while screen recording. The issue is that I have a scroll duration longer than
2
minutes I get aError processing URLs: ProtocolError: Runtime.callFunctionOn timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
Error. Just wondering what could be the reason. Could possibly be an async issue? I am setting the time in my autoscroll functionEntire Error Log
Entire script
The text was updated successfully, but these errors were encountered: