3

i have been working in a video website [platform: php] where i need to upload videos in Amazon S3 server and extract thumbnail.

I have created a bucket and uploaded video file successfully in that bucket. But i don't know how to extract the thumbnail from that uploaded video. So, that's where i stuck.

Any help will be appreciated. Thanks in advance!

ajduke
  • 4,991
  • 7
  • 36
  • 56

2 Answers2

5

Here you've got some options.

First - you can "extract" a thumbnail from the video before you upload it to AWS. Something like: upload video to your server, convert it to appropriate format if needed, take a thumbnail (or thumbnails), save them somewhere (e.g. on S3 or your local server) and then upload the video to S3. The disatvantage of this method is that your local server will have to do a lot of extra work, instead of serving your web visitors.

Second - you can use Amazon EC2 computing service for that: upload video to S3, trigger EC2 (e.g. with cron jobs) to take the video from S3, convert it, take thumbnails and upload the final result (converted video + thumbnails) back to S3. Disatvantages are: it's not very easy to implement this "communication" (you'll have to solve a lot of problems, like ensuring stable converts, creating job queues etc.), plus you'll have to use one more AWS service along with S3.

What's about video converting and getting thumbnails? There are many tools and programs for that. I like using ffmpeg for video converting (also there's PHP wrapper for using it's functionality with php - php-ffmpeg, but using ffmpeg itself (e.g. using php's exec() function) will give you more flexibility and features, please read documentation for more details). FFMpeg can extract thumbnails from videos as well, but it takes some time (there are lots of discussions about how to do it effectively), but I'd suggest you to use ffmpegthumbnailer for this purpose. It has simpler usage and is optimized especially for getting thumbnails from video files.

vitalikaz
  • 568
  • 4
  • 13
  • Thanks for your answer. I have already developed the FFMPEG for video conversion and thumbnail generation in this website. But my client want to do the same using Amazon [for better speed]. So, if there is no such direct way then it seems i have to follow your Cron Job concepts. And yes, after reading your message me too quite sure it's not gonna be a easy one :) – Debasish Chowdhury Jan 10 '13 at 13:02
  • 1
    Yes, you can't do this with S3 only, because it's **storage** service, and for processing purposes there's Amazon EC2 – vitalikaz Jan 10 '13 at 13:12
1

You should do this on the machine you are using for the upload. Here you have direct file-system access to the file. Once it is in S3 it is accessible via HTTP only.

The tool ffmpeg can be used to create a thumbnail of many video formats.

Example:

ffmpeg -i "video.flv" -ss 00:00:10 -f image2 "thumbnail.jpg"

Would create a thumbnail at video second 10 and save it as thumbnail.jpg When using PHP you can use system to execute

Michel Feldheim
  • 17,625
  • 5
  • 60
  • 77