Giter VIP home page Giter VIP logo

youtube-screenshot's Introduction

YouTube Screenshot

Capture high-quality, precise-frame screenshots from YouTube videos with this Node.js library. Perfect for content creators, researchers, and developers looking to integrate YouTube video snapshots into their projects.

Installation

Install via NPM:

npm install youtube-screenshot

Usage

Quickly integrate YouTube Screenshot into your Node.js applications:

const takeScreenshot = require('youtube-screenshot');

const videoUrl = 'https://www.youtube.com/watch?v=example';
const timestamp = '00:01:00'; // Timestamp for the screenshot
const outputPath = './'; // Output directory
const filename = 'screenshot.png'; // Output filename

takeScreenshot(videoUrl, timestamp, outputPath, filename)
    .then(() => console.log('Screenshot taken successfully'))
    .catch(err => console.error(err));

API Reference

takeScreenshot(videoUrl, timestamp, outputPath, filename)

  • videoUrl: URL of the YouTube video.
  • timestamp: Time at which to take the screenshot (format: HH:MM:SS).
  • outputPath: Directory where the screenshot will be saved.
  • filename: Name of the output file.

Returns a Promise that resolves when the screenshot is successfully taken.

example.js

Sample code that showcases how to use youtube-screenshot in your code as async/await

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);

youtube-screenshot's People

Contributors

anuragphadke avatar weaveroftheweb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.