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

ts-whammy

v1.1.5

Published

A modern typescript version of whammy. You can use it to encode images(webp) to webm video.

Downloads

767

Readme

Github | Npm | Home


ts-whammy

A modern typescript version of whammy. You can use it to encode images(webp) to webm video.

ts-whammy only includes the core video encoding functions of whammy, you can use it whatever modern frontend stack you prefer.

Status

Quick start

ts-whammy

npm install ts-whammy -S
// for js
import tsWhammy from 'ts-whammy'

// for ts
// import tsWhammy from 'ts-whammy/src/libs'

// image URLs can from: canvas.toDataURL(type, encoderOptions)
const images = ['data:image/webp;base64,UklGRkZg....',
  'data:image/webp;base64,UklGRkZg....']

// create a video at 1 FPS
const blob = tsWhammy.fromImageArray(images, 1)
// create a 5 second video
const blob = tsWhammy.fromImageArrayWithOptions(images, { duration: 5 })

console.log(blob.type, blob.size)

Usage

Compatibility

  • node
  • browsers (must support webp): https://caniuse.com/#feat=webp

Performance

# test data
images info length(5),
total base64 size(157.37890625 kb),
total blob size(118.029296875 kb)

# MacBook Pro I7 2.2G
# node v10.13.0, benchmark
--- testFromImageArray ---
fromImageArray x 63.06 ops/sec ±2.74% (64 runs sampled)

# chrome 79, simple loop test
--- start test total count(100) ---
...
...
end test total count(100),
time(697 ms),
avg time(6.97 ms),
ops/sec (143.47202295552367),
webm size (118.1572265625 kb)

Docs

index

fromImageArray(images: string[], fps: number, outputAsArray?: boolean): Blob | Uint8Array
  • images: An array of image base64 strings, image type must be 'image/webp', see more: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL. images must have same width and height, must not have Alpha Channel
  • fps: frames per second number, FPS number can't be 0. (if you set FPS to equal 0, FPS will be reset to default of 1).
  • outputAsArray: return Uint8Array output, the default output is Blob. In node environments, the output always be Uint8Array.
fromImageArrayWithOptions(images: string[], options: IFromImageArrayOptions = {}): Blob | Uint8Array
  • images: Same as `fromImageArray's images
  • options:
    • fps: Same as fromImageArray's fps
    • duration set output video's duration in seconds. This will adjust the video's FPS to make sure the video has the exact duration.
    • outputAsArray: Same as fromImageArray's outputAsArray
async fixImageDataList(images: string[], options?: ImageSrcToWebpDataUrlOptions): Promise<string[]>

This function can make common image(jpg,png,webp...) url or base64 to be an valid webp image. Then can send it to fromImageArrayWithOptions make an video. See this demo: Convert Canvas-recorded images into a video

  • images: An array of image url or base64.
  • options
    • width: image width for all, use it to fix image width
    • height: image height for all, use it to fix image height
    • backgroundColor: image background color, use it to fix image alpha channel

Contribution

Feel free to contribute this project.

TODO

  • update the demo, support [✅ ]record canvas/[TODO]HTML, ✅ upload images to video...
  • [✅]upgrade docs to astro
  • [✅]support build out the esm lib
  • update tests case, up test codecov