Hello is there a way in PHP to save an image from video/quicktime video ?
It's not possible in pure PHP. You would have to use an external command line tool like ffmpeg - but that makes the script less portable to other servers.
The only other idea that comes to mind is the Snapshot plugin to the LongTail Video player. With that, you can manually send snapshots of a video playing in the video player (an embeddable Flash player) to a server side script. The process can't be automated, though, and the video will need to be a FLV or MP4 one for this to work.
Related
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
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
We've currently developed an ExpressionEngine site (php), and are using a paid JWPlayer to display video uploaded by the client.
At present we're running into a number of issues, as the client is:
Uploading video at the wrong size
Uploading video randomly in both flv or mp4 format
And the player is chugging along terribly with multiple pauses throughout the video - sometimes buffering the entire clip before it is played.
I know FFMPEG can be installed serverside, but I'm not sure of the way in which to go about this, and how it might interact between ExpressionEngine and JWPlayer. I'm also not sure about the formatting - the ability for this automated encoding process to also crop/resize the video to suit the player dimensions on the site.
We would really like to have the videos playable on all browsers & iOS devices.
A HQ option would also be great where applicable, but it's just a nice to have - as we're struggling with the formatting / encoding issues first and foremost.
Any help figuring out the best process, and what tools I might need would be greatly appreciated.
I'd reccomend using a service like zencoder
I've used them in the past and no matter what video format I've thrown at them it works great. (PS. I'm not affiliated with them at all)
There is a PHP API with a whole lot of resizing, quality and format options. After you've uploaded your video you can send it to zencoder and they'll send you a response some time later with success or fail.
They can put the processed video on Amazon S3 or FTP it to a server.
You'll need a HTML5 player for iOS devices though, unless JWPlayer has come a long way since I used it last.
You could get zencoder to output in mp4. and then you still only need mp4 for JWPlayer/flash and the HTML5 version for iOS, as long as your happy to use flash for all desktop browsers there's no problem.
As far as the buffering issues you are having - I have found that using a CDN version of the swf for JWPlayer (or whatever player you are using) has caused it to load the entire video file before playing. Easily fixed by hosting it yourself.
I have found many times the video conversion capabilities of different CMS to be limited, and often restricting video formats to what the developers thought was appropriate, such as FLV, which nowadays is turning obsolete for video delivery.
One of the ways you can approach it is by creating a custom script to process the videos uploaded by your client using FFmpeg, which in fact can accept almost any video format, and generate the correct output formats and dimensions, ensuring that the resulting videos will be suitable for web playback using your player.
The problem with the video buffering you are facing is because the video file is not prepared for progressive download or pseudo-streaming, so your browser needs to download the whole video before starting to play. This can be solved with programs like qt-faststart for MP4 and MOV video files, and flvtool2 for FLV files. So your script would need to also optimize the encoded videos using these tools.
Also note that if you use an HTML5 video player (browser native or recent JWPlayer), then you can enjoy from random seeking the video files without buffering them.
If starting from scratch is not an option, you can look into a commercial solution like tremendum transcoder which also uses FFmpeg and is quite simple to use, yet it does all you need in regards to dealing with different input formats and aspect ratios automatically.
I have done a few setups this way, separating the CMS part from the video processing part, and it saved me some headaches.
i am using videojs to play video on my website(it's a HTML5 website) so for a better support i need to make 3 formats of each video mp4,webM,ogv.
But in my website user can upload video also.
So please tell me how can i automatically convert videos after/while uploading to these formats.
I am using PHP5+JS for development.
As the conversion will need to happen on the server side, you will only be able to do this once the upload has been completed. HTML5 is great but is does not support video transcoding.
I would suggest to have a look at ffmpeg, it's an extremely powerful command line utility that allow you transcode your video's with the finest precision, in fact youtube uses this to convert their video's as well.
It is a free tool and there is more than enough documentation to get you started at
http://ffmpeg.org/
We have a system set up in PHP where the upload occurs, conversion then takes place and the videos appear to the clients once the conversion is complete. However, one thing to note... I have always had trouble with ffmpeg conversions for iPhone, iPad, iPod, iOS, etc.
Is it possible to play the video (mp4) in real time using some flash player? What I mean by in real-time is that player would receive data on the fly, not from alredy saved file but e.g. php script (which sends appropriate content-type header) THAT IS DOWNLOADING AND 'ECHO-ing' THE FILE AT THE TIME PLAYER PLAYS IT - like e.g. some kind of live stream.
JW Player can play streaming video, and LongTail Video also has some good (practical) info on streaming in general:
http://www.longtailvideo.com/support/search/google_cse_adv/streaming
Edit: Maybe I didn't read the question quite as well as i ought to before I answered, but here is info on so called pseudo streaming that can be implemented in PHP:
http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12534/video-delivery-http-pseudo-streaming
For instant playback using flash, you need to format your mp4 file to have the moov header box at the front of the file for playback to start right away. This can be done by the qt-faststart utility.
To allow for seeking in the file using flash (to a portion of the file not downloaded) you need to utilize pseudo streaming. (Since flash has disabled the partial bytes header). This needs to be implemented on the server side: http://h264.code-shop.com/trac as well as the flash side (both jwplayer and flowplayer supports this approach, and sends ?start=123 param on seek)
The other option is to use the html5 tag (but mp4 is only supported in a few browsers) - then you do not need the pseudostreaming backend.
You can use VLC media player from:
http://www.videolan.org/vlc/
After you successfully installed it, click on the menu Media->Open Network Stream and fill in the URL for the video.