AWS for M&E Blog
Create a poster frame and thumbnail images for videos using AWS Elemental MediaConvert
If you develop video applications, you probably need to create poster frames (a highlight image that is representative of a video) and thumbnail images (periodic frame grabs over the duration of the entire video) as a part of your workflow.
Have you ever wondered how to create a poster frame for a specific frame in your video clip? Or how to create a specified number of thumbnails for the video assets in an automated workflow? Wouldn’t it be great if thumbnail captures were spread out evenly within your video, so you have an easy way to promote your videos to your customers?
In this blog post you will learn how to create a poster frame and image thumbnails from video assets using AWS Elemental MediaConvert. I’ll also provide some helpful tips about how to use the configuration options available with the service.
If you want to get started building a video-on-demand workflow quickly, use the Video on Demand on AWS solution. A comprehensive workshop is also available on github for building simple VOD workflows.
Now let’s dive into creating a poster frame and thumbnails.
Create a poster frame at a specific frame number
To create a poster frame, start by adding a new output group in your AWS Elemental MediaConvert Job settings. Click Add button under Output groups in the left menu bar, select File group option and click the Select button. Configure your Custom group name, Destination, Name modifier, and Extension for Outputs. Next click Output 1, which leads you to Output settings as shown below.
To create frame capture, select No Container in Container dropdown box, and select Frame Capture to JPEG in Video codec dropdown box. The most important parameters are entered in the Framerate text field.
In this example, I’m using a video clip that is 5 minutes in duration with a framerate of 30 frames per second (FPS). The first text field is the video framerate, so I enter 30 here. The second text field is the frame number that I want to capture as my poster frame. In this example I’ll choose frame number 88.
Tip: You need to set the Max captures to 2, because MediaConvert always captures the first frame of the video.
The Resolution (w x h) text fields can be left empty to just use the input video resolution, or they can be set to values to match particular frame capture requirements. In addition, you can control the Scaling behavior by using the Default or Stretch to output options. Default tells MediaConvert to letterbox the image, maintaining the same aspect ratio as the input video, while Stretch to output means the image will be stretched to the resolution specified.
Tip: This configuration can be read as “capture a frame to a JPEG file every 88 frames, with video framerate of 30 FPS, for a maximum of 2 captured images”.
Once the job completes, I will find two poster frame JPG images in my output S3 bucket. The second image file (clip-poster.0000001.jpg) is the 88th frame capture.
Create image thumbnails spaced evenly throughout the video
To create a set of thumbnails, follow the same steps you did above to create the poster frame capture, but here you’ll need to do some quick math to calculate what to use in the second Framerate field. The first text field in Framerate is still your video’s framerate – which is 30 in my example.
To calculate the second number, start with the duration. The video clip used in my example is a 5-minute video clip, which is a duration of 300 seconds (5 mins * 60 seconds). Next calculate the total frames in the video by multiplying this duration (in seconds) by the framerate (300 seconds * 30 FPS). This gives us 9,000 total frames. For thumbnail images distributed evenly throughout the video, use the total number of frames divided by the number of thumbnails required (we’ll use 10 in my example), so this calculation (9,000 / 10) gives us the value 900. So we can now enter 900 into the second text field in Framerate as shown below.
Tip: This configuration can be read as “capture a frame to a JPEG file every 900 frames, with video framerate of 30 FPS, for a maximum of 10 captured images”.
When the job finishes, here are all the frame captures in my S3 bucket:
That’s it. AWS Elemental MediaConvert provides high quality, broadcast-grade video transcoding to create on-demand video assets for delivery to televisions or connected devices. With a little scripting help, you can automate the workflow for all your video assets on AWS.