视频托管 - 压缩视频?
我计划将视频添加到我的网站(1 分钟长或更少的简短问候剪辑)。由于这是一家初创公司,视频大小非常重要。
什么格式最适合存储上传的视频(例如:mp4、avi、mpeg、flv)? 要求:质量应该足够好,同时保持文件大小尽可能小。
我的平台是 PHP。如果用户以不同格式上传视频,是否有用于视频压缩/转换的内置或开源框架?对于照片,我们使用imaggemagik;有类似的视频吗?
理想情况下,我想避免使用 Flash 视频播放器。有更好的选择吗?
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 is 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
包含 h.264 的 mp4。然后WebM作为备份。
ffmpeg 似乎很受欢迎
您至少需要 Flash 来实现向后兼容,但在 h.264 和 WebM 之间,您将获得 HTML 5 视频的广泛支持。
mp4 containing h.264. Then WebM as a backup.
ffmpeg seems popular
You'll need Flash for backwards compatibility at least, but between h.264 and WebM you will have wide support in HTML 5 video.
ffmpeg-php 扩展是您所需要的
http://ffmpeg-php.sourceforge.net/
the ffmpeg-php extension is what you need
http://ffmpeg-php.sourceforge.net/
mp4 容器和 h264 编解码器是所有浏览器都支持的唯一“一对”。
h265 和 VP9 提供更好的压缩比,但仍然部分受支持,并且在大多数平台上可能没有硬件加速。
对于 h264,通过双通道编码您将获得更好的压缩效果。第一遍创建有关第二遍中使用的视频运动的统计数据。请参阅 ffmpeg 相关文档。
此外,与降低质量参数相比,编码到较小的输出分辨率会产生更好的质量。也就是说,如果您有分辨率为 1080x720 的原始视频,编码为最终 (1080/3)x(720x3) 输出将节省大约 9(3x3) 带宽。所欣赏的质量比以原始比特率 1/9 传输 1080x720 的流要好得多。这是由于大脑的工作方式造成的。
一个好的方法是提供视频的高-中-低表示,并通过 JS 为客户端检测最佳视频。将全高清流式传输到 3G 客户端或将 1080p 视频流式传输到具有 800x400 屏幕的客户端没有任何意义。
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.
考虑使用 http://m.vid.ly 等服务或更全面的服务(例如https://xmaven.com - 这些解决了复杂视频设置带来的麻烦,并且完全可扩展
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