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 🙏

© 2024 – Pkg Stats / Ryan Hefner

thumbsupply

v0.4.0

Published

Asynchronous thumbnail supplier with caching for Node.js

Downloads

1,925

Readme

thumbsupply

Asynchronous Node.js module to create, cache and fetch thumbnails from videos. It uses ffmpeg to generate thumbnails and ES6 Promise.

The API is more reliable now and is unlikely to have major changes before stable release.

Healthy criticisms, feature requests and issues are welcome.

NOTE: Since v0.2, the module no longer maintains thumbnails separately for each application. This behavior is intended to improve the performance and utilize caching as far as possible.

Installation

npm install thumbsupply

Usage

Generating Thumbnails

The resolved promise gives filepath of the generated thumbnail. In case of modifications to be performed on the generated thumbnail, it's recommended to work on a copy.

Using generateThumbnail() method by default enables caching to speeden up the process.

const thumbsupply = require('thumbsupply');

thumbsupply.generateThumbnail('some-video.mp4')
    .then(thumb => {
        // serve thumbnail
    })

It accepts options to control timestamp and size of the thumbnail. The forceCreate option can be used to generate the thumbnail every time. Mimetype of the file can be specified using mimetype option. It overrides mimetype derived from the file extension and can be used for cases where such derivation is not possible. cacheDir allows configuring the directory to store the thumbnail cache. Unless there is an explicit need, it is good to use shared cache.

const thumbsupply = require('thumbsupply');

thumbsupply.generateThumbnail('some-video.mp4', {
    size: thumbsupply.ThumbSize.MEDIUM, // or ThumbSize.LARGE
    timestamp: "10%", // or `30` for 30 seconds
    forceCreate: true,
    cacheDir: "~/myapp/cache",
    mimetype: "video/mp4"
})

NOTE: Thumbnails which are older than the video get expired automatically.

Look up Thumbnails

Instead of creating a thumbnail, sometimes you may need to get the thumbnail if it exists.

const thumbsupply = require('thumbsupply');

thumbsupply.lookupThumbnail('some-video.mp4')
    .then(thumb => {
        // serve thumbnail
    })
    .catch(err => {
        // thumbnail doesn't exist
    });

Features on the way

thumbsupply will soon be supporting music, pictures and so on. The architecture required is already shipped.

Developers can experiment with some of the non public API's to create thumbnail suppliers supporting new formats. Documentation on how to do that will be released with the production version.

External bugs

  • ffmpeg is producing screenshots which mismatch the resolution specified by 1 unit.