Skip to content Skip to sidebar Skip to footer

Get Video Resolution Of A Video File Using Amazon Elastic Transcoder

We have this configuration working: 1- Display a JS Upload Form to the visitor 2- Upload file chosen direclty to Amazon S3 3- Transcode the Video in MP4 using Amazon Elastic Transc

Solution 1:

I have a method that might work for you, but I'd just like to mention that not having direct access to metadata about uploaded videos directly limits the usefulness of the elastic transcoder service to the point where I'd strongly recommend using an alternative like encoding.com (ironically their own servers are hosted on AWS).


So my solution is that you could use a preset for encoding jobs that creates thumbnail files that match the aspect ratio of the original uploaded video by setting it to "auto":

The aspect ratio of thumbnails. If you want Elastic Transcoder to automatically detect the aspect ratio in the input file and use that value for thumbnails, select auto. If you want to specify the aspect ratio for thumbnails, select the applicable value.

At this point, you now have two ways to actually access the original video's aspect ratio (both of which involve JavaScript):

1. Write JS that downloads the first thumbnail file, and explicitly parse the image dimensions and calculate the aspect ratio by dividing width by height.

OR

2. Specify a ThumbnailPatternwhen you create the original job that will generate thumbnail filenames that include the resolution of the image file by using the "{resolution}" placeholder:

Thumbnail Filename Pattern

{resolution} (Optional): If you want Elastic Transcoder to include the resolution in the file name, include {resolution} in the field.

Then you can , so you just need to get the first image thumbnail for an encoded video and use JS to parse the filename for the resolution and calculate the aspect ratio.

Both methods are kind of hacky, but benefit from not needing to do any additional video processing, and in the future when/if AWS gives you access to the metadata you should have a very easy upgrade path that eliminates this kludge.

Based on the responses from the AWS devs in Amazon's forums, accessing video metadata is probably going to become available in the near future, so I guess you also have the third option of waiting and this problem might solve itself.

Solution 2:

It's now possible to retrive any information about the input video and the output video of a job: http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/get-job.html

Post a Comment for "Get Video Resolution Of A Video File Using Amazon Elastic Transcoder"