Lambda to trigger a Fargate container that generates videos thumbnails after a file be uploaded and save it into S3
MIT License
This application trigger a container with ffmpeg to generate thumbnails when a video is uploaded into a S3 Bucket folder. Output example (compressed file for faster load):
npm install
Or simply:
yarn
Was installed and configured the
eslint
andprettier
to keep the code clean and patterned.
Deploy the application:
$ sls deploy
Now push the container image:
$ cd scripts
$ ./deploy-container.sh
The script will:
This container make usage of the aws cli to download the mp4 video file uploaded in the S3 Bucket, makes some calculations, then it uses ffmpeg binary to capture a thumbnail at each 1 second of video and save them into a single file.
Refer to the
docker/main.sh
script.
Once the thumbnails file is generate it is uploaded into S3 Bucket.
To completly remove the resources from AWS, follow these steps:
$ cd scripts
$ ./teardown.sh
$ sls remove
That is all.
After deploy the application use the outputed Lambda URL to request a signed URL to upload a video file:
GET /signedURL
Then use the signedUrl
to upload the video file:
PUT <signed URL>
Once the upload finish S3 will trigger a Lambda that will fire a container to generate the video thumbnails file, all you need to do is wait the generated file be uploaded in the same S3 Bucket in a folder called preview
.
Jest was the choice to test the app, to run:
$ yarn test
Or:
$ npm run test
Run the command in the root folder
You can see the coverage report inside tests/coverage
. They are automatically created after the tests run.