All Projects → deek87 → lamba-thumbnailer

deek87 / lamba-thumbnailer

Licence: MIT license
AWS S3 Video Thumbnailer with Lambda

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to lamba-thumbnailer

Node S3 Uploader
Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK for transfer, and ImageMagick for image processing. Support for multiple image versions targets.
Stars: ✭ 237 (+1028.57%)
Mutual labels:  thumbnails, aws-s3, s3
0x4447 product s3 email
📫 A serverless email server on AWS using S3 and SES
Stars: ✭ 2,905 (+13733.33%)
Mutual labels:  aws-s3, s3
Mc
MinIO Client is a replacement for ls, cp, mkdir, diff and rsync commands for filesystems and object storage.
Stars: ✭ 1,962 (+9242.86%)
Mutual labels:  aws-s3, s3
Rust S3
Rust library for interfacing with AWS S3 and other API compatible services
Stars: ✭ 177 (+742.86%)
Mutual labels:  aws-s3, s3
imtool
🖼️ Client-side canvas-based image manipulation library.
Stars: ✭ 38 (+80.95%)
Mutual labels:  thumbnails, thumbnail-generator
Sbt S3 Resolver
☁️Amazon S3-based resolver for sbt
Stars: ✭ 112 (+433.33%)
Mutual labels:  aws-s3, s3
Are We Consistent Yet
Compare eventual consistency of object stores
Stars: ✭ 157 (+647.62%)
Mutual labels:  aws-s3, s3
Minio Hs
MinIO Client SDK for Haskell
Stars: ✭ 39 (+85.71%)
Mutual labels:  aws-s3, s3
nano photos provider2
PHP photos provider for nanogallery2
Stars: ✭ 37 (+76.19%)
Mutual labels:  thumbnails, thumbnail-images
thumbnailme
Thumbnail me is an open source software project based on the ‘Movie Thumbnailer’ binary.
Stars: ✭ 63 (+200%)
Mutual labels:  thumbnails, thumbnailer
hls-live-thumbnails
A service which will generate thumbnails from a live HLS stream.
Stars: ✭ 49 (+133.33%)
Mutual labels:  thumbnails, thumbnail
Nestjs Multer Extended
💪 Extended MulterModule for NestJS with flexible S3 upload and helpful features
Stars: ✭ 99 (+371.43%)
Mutual labels:  aws-s3, s3
Rpizero smart camera3
Smart security camera with Raspberry Pi Zero and OpenFaaS
Stars: ✭ 58 (+176.19%)
Mutual labels:  aws-s3, serverless-functions
Terraform Aws S3 Bucket
Terraform module which creates S3 bucket resources on AWS
Stars: ✭ 130 (+519.05%)
Mutual labels:  aws-s3, s3
Radosgw Admin4j
A Ceph Object Storage Admin SDK / Client Library for Java ✨🍰✨
Stars: ✭ 50 (+138.1%)
Mutual labels:  aws-s3, s3
Kafka Connect Storage Cloud
Kafka Connect suite of connectors for Cloud storage (Amazon S3)
Stars: ✭ 153 (+628.57%)
Mutual labels:  aws-s3, s3
S3proxy
Access other storage backends via the S3 API
Stars: ✭ 952 (+4433.33%)
Mutual labels:  aws-s3, s3
Aws S3 Scala
Scala client for Amazon S3
Stars: ✭ 35 (+66.67%)
Mutual labels:  aws-s3, s3
Retinal
🏙 Retinal is a Serverless AWS Lambda service for resizing images on-demand or event-triggered
Stars: ✭ 208 (+890.48%)
Mutual labels:  aws-s3, serverless-functions
crops
🌄 Image thumbnail generation server
Stars: ✭ 37 (+76.19%)
Mutual labels:  thumbnails, thumbnail

Build

IMPORTANT

This branch is currently under development and is provided as is

Roadmap for TypeScript

  • Convert All Code to TypeScript (done)
  • Use FFmpeg Layers for Lambda instead (done)
  • Make the thumbnailer more moduler (in-progress)
  • Implement Tests (to be done)

Table Of Contents

Introduction

This package was created to automatically generate thumbnails from s3 video uploads.

Getting Started

Install this package using the following the command then require the package in your code.

npm install lambda-video-thumbnailer

Using in your own function

You can use the provided s3example.js to get you started. Or you can use the following code snippet for a lambda function.

// Require the library
const lvt = require("lambda-video-thumbnailer");

exports.handler = function (event, context) {
  // Returns a S3Thumbnailer Class
  const t = new lvt.S3(event.Records[0].s3);
  // Create a thumbnail will return promise<string>
  return t.createThumbnail({
    width: 100,

    height: 100,

    time: "00:00:05",

    type: "webp",
  });
};

Thumbnail Configuration

createThumbnail() takes a thumbnailConfig object with that has the following default options

{
  "prefix": "thumbnails/",
  "width": 180,
  "height": 180,
  "time": "00:00:05",
  "type": "jpg",
  "quality": 2,
  "thumbnailOption": "default"
}

Size

To configure the output size of thumbnails simply supply a width/height number. If you want to automatically calculate width or height based on the aspect ratio of the input, just use -1. For example:

{
  "width": 700,
  "height": -1
}

This will produce a 700x300 image when the input aspect ratio is 21:9

If your output needs to be a multiple of n then supply -n and it will output an output that is scaled by the ratio and a multiple of -n. For example

{
  "width": -3,
  "height": 250
}

This will produce a 441x250 image when the aspect raito is 21:9

Type

To configure the output type of thumbnails just set the type to "jpg", "png" or "webp"

{
  "type": "webp"
}

NOTE: ffmpeg with png tends to output very large filesizes even with -pred mixed

Quality

The output quality of the thumbnail is controlled by the quality property. It is controlled on a scale of 1-10 with 1 being the best quality and 10 being the worst quality.

{
  "quality": 1
}

Thumbnail Option

This option determines which filter to use for capturing thumbnails via ffmpeg. The options currently are default,none. The default option will set the filter to thumbnail this will look for the best frame within the select timeslot, this can be use quite a bit of memory on large files but will generally give the best screenshots. none will not use any filter and pick the first frame at the given timeslot.

{
  "thumbnailOption": "none"
}

Output Location

The output bucket is defined by the outputBucket thumbnail config option, by default this will output the files to the source bucket if left blank.

{
  "outputBucket": "mybucket"
}

By default the output file name will use the source file with the new type suffix. For example movie_trailer.mp4 becomes move_trailer.jpg when used with the jpg type output. However you can customize it with the outputKey option in your thumbnail config. It will still attach the type or replace it my_new_filename.hello becomes my_new_filename.jpg

{
  "outputKey": "my_new_filename"
}

Setup the Lambda Function

This package requires a ffmpeg layer to function. You can use the following arns:

Or alternatively use the serverlesspub build (only available in ap-us-east-1) arn:aws:lambda:us-east-1:145266761615:layer:ffmpeg:4 or build your own from their github repo serverlesspub/ffmpeg-aws-lambda-layer

Then just go onto AWS Lambda create a new function and give it a trigger of put objects with a suffix filter of _.avi, _.mov etc..

Although you don't need to do this it just reduces the number of invocations. Apply a policy of LambdaExecute to the IAM role (this gives read and write access to s3) then set the memory limit to the maximum* and set timeout for 30seconds (again it normally takes around 6 seconds but its good to be safe).

*NOTE: I have never reached the maximum with this function, its normally around 700mb even for 4gb mov files

Lambda Layers

Asia

  • arn:aws:lambda:ap-east-1:260572601982:layer:ffmpeg:1 - Hong Kong (AP East 1)
  • arn:aws:lambda:ap-south-1:260572601982:layer:ffmpeg:1 - Mumbai (AP South 1)
  • arn:aws:lambda:ap-northeast-2:260572601982:layer:ffmpeg:1 - Seoul (AP Northeast 2)
  • arn:aws:lambda:ap-southeast-1:260572601982:layer:ffmpeg:1 - Singapore (AP Southeast 1)
  • arn:aws:lambda:ap-southeast-2:260572601982:layer:ffmpeg:1 - Sydney (AP Southeast 2)
  • arn:aws:lambda:ap-northeast-1:260572601982:layer:ffmpeg:1 - Tokyo (AP Northeast 1)

Europe

  • arn:aws:lambda:eu-central-1:260572601982:layer:ffmpeg:1 - Frankfurt (EU Central 1)
  • arn:aws:lambda:eu-west-1:260572601982:layer:ffmpeg:1 - Ireland (EU West 1)
  • arn:aws:lambda:eu-west-2:260572601982:layer:ffmpeg:1 - London (EU West 2)
  • arn:aws:lambda:eu-west-3:260572601982:layer:ffmpeg:1 - Paris (EU West 3)
  • arn:aws:lambda:eu-north-1:260572601982:layer:ffmpeg:1 - Stockholm (EU North 1)

Canada

  • arn:aws:lambda:ca-central-1:260572601982:layer:ffmpeg:1 - Central (CA Central 1)

South America

  • arn:aws:lambda:sa-east-1:260572601982:layer:ffmpeg:1 - São Paulo (SA East 1)

United States

  • arn:aws:lambda:us-east-1:260572601982:layer:ffmpeg:1 - North Viginia (US East 1)
  • arn:aws:lambda:us-east-2:260572601982:layer:ffmpeg:1 - Ohio (US East 2)
  • arn:aws:lambda:us-west-1:260572601982:layer:ffmpeg:1 - N. California (US West 1)
  • arn:aws:lambda:us-west-2:260572601982:layer:ffmpeg:1 - Oregon (US West 2)

Original Tutorial

Originally this was a tutorial I wrote back in July 2017, I updated it a bit since then. The original also contained mediainfo. Available Here

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].