使用 ffmpeg 服务器端即时转换多个文件
我正在创建一个允许用户上传音频的网站。我刚刚想出了如何使用 ffmpeg 和 PHP 来即时转换音频文件(从 WAV 到 MP3)。
我对 ffmpeg 没有任何实际经验,我想知道转换文件的最佳方法是什么。我不会在页面加载时转换它们,我会将转换放入队列中并单独处理它们。
我对如何最好地处理队列有疑问。在不使服务器超载的情况下转换这些文件的合适间隔是多少?我应该同时处理文件还是逐个处理文件?每个时间间隔应该转换多少个文件才能使服务器有效运行?
服务器规格
- Core i3 2.93GHz
- 4GB RAM
- CentOS 64位
我知道这些问题非常模糊,但如果有人有类似概念的经验,我真的很想听听什么对他们有用以及什么常见我在未来的道路上可能会遇到的问题。
真的很感谢所有的帮助!
I am in the process of creating a site which enables users to upload audio. I just figured our how to use ffmpeg with PHP to convert audio files (from WAV to MP3) on the fly.
I don't have any real experience with ffmpeg and I wanted to know what's the best way to convert the files. I'm not going to convert them upon page load, I will put the conversions in a queue and process them separately.
I have queries about how best to process the queue. What is a suitable interval to convert these files without overloading the server? Should I process files simultaneously or one by one? How many files should I convert at each interval to allow the server to function efficiently?
Server specs
- Core i3 2.93GHz
- 4GB RAM
- CentOS 64-bit
I know these questions are very vague but if anyone has any experience with a similar concept, I would really love to hear what works for them and what common problems I could face in the road ahead.
Really appreciate all the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您使用像 beanstalkd 这样的工作队列。当有新文件要转换时,只需将消息放入队列中(可能是文件名)。作为 beanstalkd 客户端工作的守护进程会获取消息并正确转换音频文件(该守护进程可以用具有 beanstalkd 库的任何语言编写)。
I suggest you use a work queue like beanstalkd. When there is a new file to convert simply place a message into the queue (the filename maybe). A daemon that works as beanstalkd client fetches the message and converts the audio file properly (the daemon can be written in any language that has a beanstalkd library).