-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.js
18 lines (15 loc) · 845 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const takeScreenshot = require('youtube-screenshot');
async function captureYouTubeVideoScreenshot(videoUrl, timestamp, outputDir, filename) {
try {
await takeScreenshot(videoUrl, timestamp, outputDir, filename);
console.log(`Screenshot saved as ${filename} in ${outputDir}`);
} catch (error) {
console.error('Error taking screenshot:', error.message);
}
}
// Example usage
const videoUrl = 'https://www.youtube.com/watch?v=xQI3SDaRasM&t=4s&ab_channel=AnuragPhadke'; // Replace with actual YouTube video URL
const timestamp = 54; // The time point for the screenshot (in seconds)
const outputDir = './screenshots'; // The directory where the screenshot will be saved
const filename = 'sample.png'; // The name of the screenshot file
captureYouTubeVideoScreenshot(videoUrl, timestamp, outputDir, filename);