Reputation: 5145
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 Transcoder with options:
* resolution: auto
* thumbnails: on, every 2sec
Everything works fine. However, I need to get the original video resolution/ratio for 2 reasons. The first reason is to be able to set a good ratio for the thumbnail generations. (sometimes it's 16/9, 4/3, iphone videos...) The second reason is to display an HTML5 video player with the perfect ratio to avoid blank spaces on the sides of the player.
As Amazon Elastic Transcoder
is already detecting the video resolution automatically, I was thinking that they may have a way to return the resolution detected but... it doesn't seem so!
Anyone can think about a way to get the resolution/ratio of the video? My current solution will be to download the video back from S3 on my servers and detects the resolution using FFmpeg
or FFprobe
. Obviously, it's not ideal.
Upvotes: 3
Views: 3140
Reputation: 101
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
Upvotes: 0
Reputation: 6517
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 ThumbnailPattern
when 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.
Upvotes: 1