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!
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.
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
Related
I want to transcode video in 360p, 480p, 720p and then upload to amazon s3.
Currently we are using php library FFMPEG
I have successfully transcode video on my server. But I did not get that how to achieve same on amazon s3.
Do I need to first upload original video on s3 and then get that video and transcode in different format and send to amazon s3? is it possible?
Or if any other way than please suggest me.
S3 is not a block file system, it is an object file system. The difference here is that, normally, you cant mount a S3 bucket like a standard unix FS and work on file with fopen(), fwrite() ect... Some trick exists to work on S3 like any other FS but I would suggest an other option :
You have to transcode the video on a localy mounted FS (like an AWS EFS, or a local file system), then "push" (or upload) the whole transcoded video onto the S3 bucket. Of course, you can improve this process in may ways (remove temp file, do parallel works, use Lambda service, or task in containers...). You should avoid to do many upload/download from or to S3 (because it is time and cost consuming). Use a local storage as much as possible, then push the resulting data when they are ready on S3.
Also AWS have a service to do video transcodification : https://aws.amazon.com/en/elastictranscoder/
I have a PHP REST API that hosts all images in the Amazon S3. I'm looking for a plugin, or trick, to resize the images using GET params. For example:
http://my-bucket.s3.amazon.com/image.jpg?width=300&height=300
I found this plugin, but a member of my team said it is ASP.NET based and doesn't fit to my PHP API project. Should I use a script hosted in EC2 to resize those images? Is there other way? Ideas are welcome.
Thanks!
I suggest setting up your own PHP service to resize images based on the query string values, as you describe. Yes, the PHP service could be hosted on AWS EC2 or another hosting platform. The service would need to receive the query string such as:
http://example.com/images/image.jpg?width=300&height=300
This would need to be configured (perhaps using mod_rewrite [1]) to receive the name of the image (example: 'image.jpg') and pass the query string size values into your PHP script. The script would then find your image on S3, resize it using an image library (such as ImageMagick / PHP GD or PHPThumb [2]) save it (or not) back to S3 and also pass the image data back through on the original request.
I wish you good fortune!
[1] https://httpd.apache.org/docs/current/mod/mod_rewrite.html
[2] http://phpthumb.sourceforge.net/
There is two options available:
1) LAMBDA : if you want to go with AWS services itself the lambda is a good solution for you
http://docs.aws.amazon.com/lambda/latest/dg/walkthrough-s3-events-adminuser.html
There are AWS lambda code which can generate thumbnails based on configured values. The AWS Lambda console itself has some of them which you could tweak into a working system. The link to the console will not work unless you are logged in.
2) ThirdParty : you can use third party resizer like
Timthumb : https://github.com/GabrielGil/TimThumb
TimThumb is a simple, flexible, PHP script that resizes images. (make sure your directory having public access)
Imagine:
https://github.com/avalanche123/Imagine
Best image processing lib for a few years now. OOP, unit tested, easy to use and MIT licensed. If someone knows another one of the same quality I would be surprised and like to know about it as well. :)
EasyphpThumbnail : http://www.mywebmymail.com/?q=content/easyphpthumbnail-class
The EasyPhpThumbnail Image Effects class allows you to handle image manipulation and PHP thumbnail generation for GIF, JPG and PNG on-the-fly. The class is FREE, 100% PHP based, available for PHP4 (from 4.3.11) and PHP5, is easy to use and provides lots of functionality with over 60 manipulations:
I basically need to record a video of the flash stage, and save it as a video file on the webserver. I don't have FMS or the luxury of Java based servers like Red5 to stream to, so I am pretty much stuck with HTTP post to a php script. Now I can grab invidual snapshots (bitmapDatas) Just fine, but how can I convert them to a video file? Any help is appreciated.
PS: This is not an AIR app, so I am using flash runtime. And the video would be couple seconds long so there shouldn't be much of a performance concern at this point.
Flex provide a JPEG encoder. You can use that to compress the bitmap images and send them to the server, where you can that stitch them together using ffmpeg.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/graphics/codec/JPEGEncoder.html
I am developing a website in php hosted on a shared linux server.
I need to allow the users of my site to upload and play flv videos with flowplayer.
It would be fantastic to show a snapshot of the video before it starts, something like these: http://flowplayer.org/demos/plugins/streaming/first-frame.html
My server doesn't support pseudostreaming and it has no ffmpeg/mplayer support (it's a shared host after all...)
I am guessing how can I take a snapshot of the nth frame of the video with only php or javascript or action script.
I read something about bitmapdata class in flash >= 8, but i don't know how to do all the work automatically without the user's input.
Can someone help me?
Thanks.
AFAIK - if your server doesn't have ffmpeg, you're not going to be able to do it with PHP.
You definitely can't do it with JS.
Which leaves AS - you can create a bitmap from any display object, and save that as an image file with PHP, both of which are pretty straightforward - but you're not going to be able to run through the video to find the first frame... with AS, the image "snapshot" is the exact current visible state of the display object.
if that is enough - taking the current state of a display object and saving it as an image file - post back and i'll link a sample.
If you're on a shared Linux server, you might have ImageMagick installed. That in turn may be able to extract a screenshot of a particular frame from a movie. However this will probably only work on AVI files - MPEG movies require ffmpeg, and I am not sure about FLV files (they're not in the list of supported formats on the IM website).
Could you switch to a VPS? This will give you the root access you need to install the conversion binaries you need. These days a reasonable one with 256M-512M of RAM will cost you from 5USD pcm depending on the quality and support (I pay 4GBP pcm for a 512M box and it really has been rock solid).
Greetings all,
I have been working to get thumbnail images for a site of mine and have made some fairly decent progress. I have been able to create thumbnails of images locally and those hosted on a remote server as I had hoped.
The issue I am having is that I am unable to do the same for Videos. I have successfully installed each of the following along with their dependencies and confirm they are all working locally:
ffmpeg (and vicariously ffmpeg-PHP and ffmpegthumnailer)
Imagick (currently working for all simple "image" thumbnail creation, local and remote)
mplayer
As of yet I have been unable to find a method that would allow me to capture a thumbnail from my own video files on a remote server. The reason I am trying to connect to a remote video file is because these videos can range from 5MB to 300MB each and I don't desire to copy the entire movie locally just to create a thumbnail.
I had come across one of these that "may" allow capturing an image from a rtmp stream, which I conveniently do have access to ... but nothing fruitful came of it.
Any ideas would be greatly appreciated,
Thank you,
Silver Tiger
Update from Silver Tiger:
Looks like i had an alternative method via a third party. I used Zendcoder to convert the video files on the fly to a standard format that can play on my web project reliably, and as part of thier service, they will automatically create a dynamic thumbnail and upload it to my Amazon S3 along side the converted Video file.
Crisis averted, but in a roundabout way, and not a solution I could provide as a "solution" to anyone else unfortunately.
If you have ffmpeg installed it should be quite easy. Try something like this
$movie = 'somefile.avi'; // video file
$time = '00:03:34'; // time where to take the snapshot
$cmd = "ffmpeg -i '{$movie}' -an -ss {$time} -an -r 1 -vframes 1 -y thumb.jpg";
$escCmd = escapeshellcmd($cmd);
system($escCmd);
Maybe you could have a script on the remote server to call? This way the thumbnail is generated on the remote server, and then passed back to the front-end server.
The easiest way to do this is to install apache (or whatever you prefer) and host the thumbnail generation scripts on there.
Then all you would need to do is call:
$imageData = file_get_contents('http://remotehost/generateThunmb.php?videoid=bleh');