npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

first-last-frame

v1767774.631.530

Published

Professional integration for https://supermaker.ai/video/first-last-frame/

Readme

first-last-frame

A lightweight JavaScript library to efficiently extract the first and last frames from a video. Ideal for generating thumbnails, previews, and analyzing video content.

Installation

Install the package using npm: bash npm install first-last-frame

Usage

Here are several examples demonstrating how to use first-last-frame in your projects:

1. Basic Usage (Browser):

This example shows how to extract frames directly in a browser environment. Note that cross-origin issues may arise if the video source is on a different domain. html

2. Node.js with Canvas (Server-Side):

This example demonstrates using first-last-frame in a Node.js environment using the canvas package to process the video. Requires ffmpeg to be installed and accessible in your system's PATH. javascript const firstLastFrame = require('first-last-frame'); const { createCanvas, loadImage } = require('canvas'); const fs = require('fs');

async function extractFramesNode(videoPath, outputPathPrefix) { try { const frames = await firstLastFrame(videoPath);

const firstFrameData = frames.first;
const lastFrameData = frames.last;

const firstFrameBuffer = Buffer.from(firstFrameData.split(',')[1], 'base64');
const lastFrameBuffer = Buffer.from(lastFrameData.split(',')[1], 'base64');

fs.writeFileSync(`${outputPathPrefix}-first.png`, firstFrameBuffer);
fs.writeFileSync(`${outputPathPrefix}-last.png`, lastFrameBuffer);

console.log(`Frames extracted and saved to ${outputPathPrefix}-first.png and ${outputPathPrefix}-last.png`);

} catch (error) { console.error("Error extracting frames:", error); } }

// Example usage: extractFramesNode('path/to/your/video.mp4', 'output/frames');

3. Handling CORS (Browser):

If you encounter CORS issues, you might need to configure your server to allow cross-origin requests or use a proxy. This example shows setting the crossOrigin attribute on the video element. html

4. Using with async/await in Node.js javascript const firstLastFrame = require('first-last-frame');

async function processVideo(videoPath) { try { const frames = await firstLastFrame(videoPath); console.log('First Frame Data URI:', frames.first); console.log('Last Frame Data URI:', frames.last); // Further processing with the frame data (e.g., saving to a file). } catch (error) { console.error('Error processing video:', error); } }

processVideo('path/to/your/video.mp4');

API Summary

The first-last-frame package exposes a single function: javascript async function firstLastFrame(videoElementOrFilePath: HTMLVideoElement | string): Promise<{ first: string; last: string; }>;

  • videoElementOrFilePath: Either an HTMLVideoElement representing the video in the browser, or a string representing the file path to the video in a Node.js environment.
  • Returns: A Promise that resolves to an object containing two properties:
    • first: A base64 encoded data URI of the first frame of the video.
    • last: A base64 encoded data URI of the last frame of the video.

License

MIT

This package is part of the first-last-frame ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/video/first-last-frame/