All Projects β†’ binoculars β†’ Aws Lambda Ffmpeg

binoculars / Aws Lambda Ffmpeg

Licence: unlicense
An S3-triggered Amazon Web Services Lambda function that runs your choice of FFmpeg 🎬 commands on a file πŸŽ₯ and uploads the outputs to a bucket.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Aws Lambda Ffmpeg

Gofaas
A boilerplate Go and AWS Lambda app. Demonstrates an expert configuration of 10+ AWS services to support running Go functions-as-a-service (FaaS).
Stars: ✭ 731 (-6.28%)
Mutual labels:  aws-lambda, cloudformation
whats-your-name
Sample app for AWS Serverless Repository - uses Amazon Rekognition to recognize person on the photo
Stars: ✭ 17 (-97.82%)
Mutual labels:  cloudformation, aws-lambda
Ffmpeg Aws Lambda Layer
FFmpeg/FFprobe AWS Lambda layer
Stars: ✭ 222 (-71.54%)
Mutual labels:  aws-lambda, ffmpeg
Serverless static website with basic auth
Builds a serverless infrastructure in AWS for hosting a static website protected with Basic Authentication and published on a subdomain registered via Route 53
Stars: ✭ 112 (-85.64%)
Mutual labels:  aws-lambda, cloudformation
lambda-smush-py
Gain additional code space via cheeky compression for Python AWS Lambda functions defined in-line to CloudFormation templates.
Stars: ✭ 17 (-97.82%)
Mutual labels:  cloudformation, aws-lambda
Sumologic Aws Lambda
A collection of lambda functions to collect data from Cloudwatch, Kinesis, VPC Flow logs, S3, security-hub and AWS Inspector
Stars: ✭ 126 (-83.85%)
Mutual labels:  aws-lambda, cloudformation
amazon-ivs-simple-chat-web-demo
⚠️ IMPORTANT ⚠️ This repository is no longer actively maintained and will be archived at the end of 2022. A basic live chat implementation built with WebSockets, that can be used in conjunction with Amazon IVS to build compelling customer experiences for live video streams with chat use cases.
Stars: ✭ 53 (-93.21%)
Mutual labels:  cloudformation, aws-lambda
Cfn Generic Custom Resource
CloudFormation generic custom resource provider
Stars: ✭ 26 (-96.67%)
Mutual labels:  aws-lambda, cloudformation
nightcoreify
Randomly generates nightcore and uploads it to YouTube. A joke that got out of hand.
Stars: ✭ 54 (-93.08%)
Mutual labels:  aws-lambda, ffmpeg
serverless-data-pipeline-sam
Serverless Data Pipeline powered by Kinesis Firehose, API Gateway, Lambda, S3, and Athena
Stars: ✭ 78 (-90%)
Mutual labels:  cloudformation, aws-lambda
Lambstatus
[Maintenance mode] Serverless Status Page System
Stars: ✭ 1,323 (+69.62%)
Mutual labels:  aws-lambda, cloudformation
Aws Cognito Apigw Angular Auth
A simple/sample AngularV4-based web app that demonstrates different API authentication options using Amazon Cognito and API Gateway with an AWS Lambda and Amazon DynamoDB backend that stores user details in a complete end to end Serverless fashion.
Stars: ✭ 278 (-64.36%)
Mutual labels:  aws-lambda, cloudformation
Aws Auto Terminate Idle Emr
AWS Auto Terminate Idle AWS EMR Clusters Framework is an AWS based solution using AWS CloudWatch and AWS Lambda using a Python script that is using Boto3 to terminate AWS EMR clusters that have been idle for a specified period of time.
Stars: ✭ 21 (-97.31%)
Mutual labels:  aws-lambda, cloudformation
Autospotting
Saves up to 90% of AWS EC2 costs by automating the use of spot instances on existing AutoScaling groups. Installs in minutes using CloudFormation or Terraform. Convenient to deploy at scale using StackSets. Uses tagging to avoid launch configuration changes. Automated spot termination handling. Reliable fallback to on-demand instances.
Stars: ✭ 2,014 (+158.21%)
Mutual labels:  aws-lambda, cloudformation
Cloudmagick
CloudMagick is a serverless application which provides a dynamic image transformation like the small light module of apache2
Stars: ✭ 11 (-98.59%)
Mutual labels:  aws-lambda, cloudformation
Aws Toolkit Eclipse
AWS Toolkit for Eclipse – an open-source plugin for developing, deploying, and managing AWS applications.
Stars: ✭ 252 (-67.69%)
Mutual labels:  aws-lambda, cloudformation
Serverless Aws Lambda Node Postgres
Serverless AWS Lambda with Node.js,Postgres Rest API with Sequelize.
Stars: ✭ 18 (-97.69%)
Mutual labels:  aws-lambda, cloudformation
cfn-api-gateway-custom-domain
API Gateway custom domains as CloudFormation resources, backed by Let's Encrypt
Stars: ✭ 17 (-97.82%)
Mutual labels:  cloudformation, aws-lambda
Serverlessbydesign
A visual approach to serverless development. Think. Build. Repeat.
Stars: ✭ 254 (-67.44%)
Mutual labels:  aws-lambda, cloudformation
Lamby
Simple Rails & AWS Lambda Integration πŸ‘πŸ›€
Stars: ✭ 336 (-56.92%)
Mutual labels:  aws-lambda, cloudformation

An AWS Lambda Event-driven function that resizes videos and outputs thumbnails using FFmpeg. This function is meant for short-duration videos. If you need to transcode long videos, check out AWS Elastic Transcoder.

Dependency Status devDependency Status Known Vulnerabilities Greenkeeper badge

  • Master: Build Status
  • Develop: Build Status

The different platforms have different naming conventions for their services. To simplify this, listed below is a proposed table of generalized terms that are platform-independent.

Term Amazon Web Services Microsoft Azure Google Cloud Platform
Function Lambda Function Azure Function Cloud Function
Storage Location S3 Bucket Storage Container GCS Bucket
Storage Path S3 Key Blob Name GCS File

Function Process Overview

  1. A video file is uploaded to the source storage location
  2. A notification event triggers the function
  3. The function downloads the video file from the source location
  4. Streams the video through FFmpeg
  5. Outputs a scaled video file and a thumbnail image
  6. Uploads both files to the destination bucket

Supported Platforms

  • [x] Amazon Web Services (aws) Lambda
  • [x] Google Cloud Platform (gcp) Cloud Functions (Alpha)
  • [ ] IBM (ibm) OpenWhisk (Not started)
  • [ ] Microsoft Azure (msa) Functions (Still some work to do here)

Setup

  1. Install node.js, preferably through nvm. Each platform service uses a specific version of Node.js.
  2. Clone this repo git clone ...
  3. Run npm install
  4. Create your function code's storage location (or choose an existing one)
  5. Update the platform-specific configuration JSON file (see below), and/or modify the code file for your purposes
  6. Run Gulp (see below)
  7. Invoke the function by uploading a video to your source storage location.

Configuration

See config_samples.

At minimum, you need to modify:

  • functionBucket - The name of the bucket where your the lambda function code will be uploaded to. It's necessary for CloudFormation.
  • sourceBucket - The name of the bucket that will receive the videos and send them to the lambda for processing.
  • destinationBucket - The name of the bucket that will be used to store the output video and thumbnail image.

Local Testing

Unit Tests

  • Run npm test

Integration Tests

  • Install FFmpeg locally or use the compilation guide
  • Edit event/{platform}.json and run node test/{platform}.js, where platform is (aws|msa|gcp)
  • When switching among the platforms, reinstall the node modules if the runtime supports a different version of Node.js.
  • See the platform-specific notes

Gotchas

  • Gzipping videos will cause Safari errors in playback. Don't enable gzip unless you don't care about supporting Safari.

Platform-specific notes

AWS Lambda

  • Version information
  • Pick the largest memory allocation. This is mostly CPU bound, but Lambda bundles memory and CPU allocation together. Memory size is 1536 by default, in the CloudFormation template. Testing with different videos and sizes should give you a good idea if it meets your requirements. Total execution time is limited!
  • The object key from the event is URL encoded. Spaces in the filenames might be replaced with + so be aware of this and handle errors appropriately. If you try to download the file with the AWS SDK for JavaScript like in this example, without handling this, it will throw an error.
  • Not handling errors with context.fail(error) will cause the function to run until the timeout is reached.

Example local testing script

# Environment variables
export AWS_ACCESS_KEY_ID=AKIDEXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY
export AWS_REGION=us-east-1
export DESTINATION_BUCKET=destination-bucket
# Note that the following variable is single-quote escaped. Use $KEY_PREFIX to get the filename minus the extension.
export FFMPEG_ARGS=$'-c:a copy -vf scale=\'min(320\\,iw):-2\' -movflags +faststart -metadata description=http://my.site/$KEY_PREFIX.mp4 out.mp4 -vf thumbnail -vf scale=\'min(320\\,iw):-2\' -vframes 1 out.png'
export USE_GZIP=false
export MIME_TYPES='{"png":"image/png","mp4":"video/mp4"}'
export VIDEO_MAX_DURATION='30'
export SSE="aws:kms" # or "aes256" if you want to put the video into an encrypted bucket
export SSE_KEY_ID="some kms key id" # if SSE="aws:kms" you must provide this key id too
# Node version
nvm use 6.10 # This is subject to change
# Babel-node test script
node node_modules/babel-cli/bin/babel-node.js test/aws.js

Gulp

Task: aws:create-cfn-bucket

Creates the CloudFormation for your CloudFormation template and Lambda function code. Run this once. Set the CFN_S3_BUCKET environment variable to the name of the bucket you want to create.

CFN_S3_BUCKET=cloudformation-bucket gulp aws:create-cfn-bucket

Environment Settings

The following environment variables must be set prior to using the rest of the gulp commands

export CFN_S3_BUCKET=cloudformation-bucket
export SOURCE_BUCKET=source-bucket
export DESTINATION_BUCKET=destination-bucket
# Note that the following variable is single-quote escaped. Use $KEY_PREFIX to get the filename minus the extension.
export FFMPEG_ARGS=$'-c:a copy -vf scale=\'min(320\\,iw):-2\' -movflags +faststart -metadata description=http://my.site/$KEY_PREFIX.mp4 out.mp4 -vf thumbnail -vf scale=\'min(320\\,iw):-2\' -vframes 1 out.png'
export USE_GZIP=false # can be true or false
export MIME_TYPES='{"png":"image/png","mp4":"video/mp4"}' # must be a JSON object with "extension": "mimeType" as the key/value pairs
export VIDEO_MAX_DURATION='30' # must be a number

Task: aws:default

Everything you need to get started. Note: You can change the stack name by setting environment variable STACK_NAME.

  • Runs the aws:build-upload task
  • Runs the aws:deployStack task

Task: aws:build-upload

  • Builds dist.zip
    • Downloads and extracts FFmpeg binaries
    • Transpiles, installs dependencies, and copies configuration
  • Uploads dist.zip to the function's S3 bucket

Task: aws:deployStack

  • Creates or updates the CloudFormation stack which includes:
    • The lambda function's execution role and policy
    • The lambda function
    • The source bucket (where videos are uploaded to), including the notification configuration
    • The destination bucket (where videos and thumbnails go after they are processed)

Task: aws:update

Run after modifying anything in the function or configuration, if you've already created the stack. This will rebuild dist.zip, upload it to S3, and update the lambda function created during the CloudFormation stack creation.

Google Cloud Functions

See the quickstart guide.

Gulp

Note: you must have the gcloud CLI tool installed.

Task: gcp:default

  • Builds everything into the build/ directory
  • Deploys the function. Note: GCF does the npm install on the server-side, so there is no need to build a zip file.

Example local testing script

# Environment variables
export GCLOUD_PROJECT=example-project-name
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
export CONFIG_FILE=../config/gcp.json
# Node version
nvm use 6.9.1 # This is subject to change
# Babel-node test script
node node_modules/babel-cli/bin/babel-node.js --presets es2015 test/gcp.js

IBM OpenWhisk (not started, HELP WANTED)

See the OpenWhisk repo

Microsoft Azure Functions (in progress, HELP WANTED)

See Azure functions reference.

Example local testing script

# Environment variables
export AZURE_STORAGE_CONNECTION_STRING=... # copy from azure console
export CONFIG_FILE=../config/msa.json
# Node version
nvm use 5.9.1 # This is subject to change
# Babel-node test script
node node_modules/babel-cli/bin/babel-node.js --presets es2015-node5 test/aws.js

Contributing

Submit issues if you find bugs or something is unclear. Pull requests are even better, especially if you can make something more generalized.

If you use it, ⭐️ it!

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].