video-thumbnail-extractor

Video thumbnail extractor microservice

Usage no npm install needed!

<script type="module">
  import videoThumbnailExtractor from 'https://cdn.skypack.dev/video-thumbnail-extractor';
</script>

README

video-thumbnail-extractor

NPM version Build status Test coverage Dependency Status License Downloads

Dynamically extract thumbnails from videos with optional cropping.

GET /:url?frame=&x=&y=&width=&height=&maxsize=

url should be encodeURIComponented. frame defaults to 0. x, y, width, and height must all be defined to be valid. Returns a jpeg image.

GET /:encryptedUrl?frame=&x=&y=&width=&height=&maxsize=

Same as above, but with encrypting the URLs instead of encoding. This is so people don't know the original video URL as well as not allow arbitrary videos. Here's how to encrypt a URL:

var crypto = require('crypto');

var hostname = 'http://localhost:3000';
var password = 'some-password-you-set';

function encrypt(url) {
  var cipher = crypto.createCipher('aes256', password);
  var buffers = [];
  buffers.push(cipher.update(url));
  buffers.push(cipher.final());
  return hostname + '/' + Buffer.concat(buffers).toString('hex');
}

Now accessing encrypt(url) + '?frame=' + index will return the image at a specific index.