Video hosting - compress video?
I am planning to add videos to my website (1 minute long or less clips for short greetings). Since this is a startup, video size is very important.
What format is the best to use for storing the uploaded video (e.g.: mp4, avi, mpeg, flv)? Requirement: quality should be decent enough while keeping the file size as low as possible.
My platform i开发者_开发技巧s PHP. Are there built-in or open source frameworks for video compression/conversion if a user uploads a video in a different format? For photos we use imaggemagik; is there anything similar for video?
Ideally, I want to avoid using a Flash video player. Is there a better option?
1) What format is the best to use for storing the uploaded video - mp4, avi, mpeg, flash, etc? (req is quality should be decent enough while keeping fiel size as low as possible).
mp4 containing h.264. Then WebM as a backup.
2) My platform is in PHP, are there built -in or open source frameworks for video compression/conversion if a user uploads a different format video? (Like for photos we use imaggemagik, similarly anything for video?)
ffmpeg seems popular
3) Ideally i want to avoid using flash for video if there is a better option?
You'll need Flash for backwards compatibility at least, but between h.264 and WebM you will have wide support in HTML 5 video.
the ffmpeg-php extension is what you need
http://ffmpeg-php.sourceforge.net/
mp4 container and h264 codec is the only "couple" supported by all browsers.
h265 and VP9 offers better compression ratio but are still partially supported and probably with no hardware acceleration in most platforms.
As for h264, you will get better compression with double pass encoding. First pass creates statistics about video motion that are used in the second pass. Consult ffmpeg documentation about it.
Also encoding to an smaller output resolution produces better quality than downgrading the quality parameters. That's, if you have an original video with 1080x720 resolution, encoding into a final (1080/3)x(720x3) output will save around 9(3x3) bandwidth. The appreciated quality is much better than streaming a 1080x720 at 1/9 of the original bit-rate. This is due to the way the brain works.
A good approach can be to offer a high-medium-low representation of the video and through JS detect the best video for the client. It doesn't make any sense to stream fullHD to a 3G client or a 1080p video to a client with a 800x400 screen.
think about making your life easy with a service like http://m.vid.ly or a more comprehensive service like https://xmaven.com - these take the headache out of messing around with complex video setups and are fully extensible
精彩评论