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):
- Node.js ^14.15.0
- Serveless Framework
- AWS Account
npm install
Or simple:
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:
- Build the container image.
- Get authentication credentials in the ECR service.
- Push the container to the ECR repository created during the deploy.
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.
- https://trac.ffmpeg.org/wiki/FilteringGuide
- http://ffmpeg.org/ffmpeg-filters.html#streamselect_002c-astreamselect
To completly remove the resources from AWS, follow these steps:
- Run the teardown script:
$ cd scripts
$ ./teardown.sh
- Then remove the stack:
$ 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.