javascript 如何在上传时将视频转换为 mp4、webM、ogv?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7088982/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to convert video to mp4,webM,ogv while uploading ?
提问by Peeyush
i am using videojsto 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.
我正在使用videojs在我的网站(它是一个 HTML5 网站)上播放视频,因此为了获得更好的支持,我需要为每个视频制作 3 种格式的 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.
我正在使用 PHP5+JS 进行开发。
回答by Stephan
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.
由于转换需要在服务器端进行,因此您只能在上传完成后执行此操作。HTML5 很棒,但不支持视频转码。
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.
我建议看看 ffmpeg,它是一个非常强大的命令行实用程序,可以让您以最精确的方式对视频进行转码,实际上 youtube 也使用它来转换他们的视频。
It is a free tool and there is more than enough documentation to get you started at http://ffmpeg.org/
它是一个免费工具,有足够多的文档可以让您开始使用 http://ffmpeg.org/
回答by Joseph Orlando
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.
我们在 PHP 中设置了一个系统,在该系统中进行上传,然后进行转换,一旦转换完成,视频就会显示给客户。但是,要注意一件事......我一直在为 iPhone、iPad、iPod、iOS 等进行 ffmpeg 转换时遇到问题。