Yas*_*sai 5 php ffmpeg video-encoding video-streaming
我正在开发一个视频流媒体网站,用户可以将视频上传到网站(使用uploadify jquery插件一次播放多个视频).
现在,我面临的问题是将视频编码为FLV以便在线流式传输.
应该何时进行视频编码过程?它应该在上传完成后立即发生(即重定向用户上传成功页面,然后使用exec命令在后台开始编码ffmpeg?)但是,使用这种方法,我如何确定编码是否成功完成?如果用户上传损坏的视频并且ffmpeg无法编码,该怎么办?我如何在PHP中处理这个?
如何排队视频编码,因为多个用户可以同时上传视频?FFMpeg有自己的编码队列吗?
我还在另一个相关的SO线程中阅读了有关gearman和消息队列选项的信息,例如redis和AMQP.这些是潜在的解决方案吗?
如果有人能回答我的问题,我将非常感激.
您应该使用一个名为gearman的软件。它是一个作业服务器,您可以使用 PHP 调用函数。您可以将进程转移到后台,它会自动处理排队。许多进程也可以并行运行。
我已经使用过它,安装和操作非常简单。
对于您的用例,
Run Code Online (Sandbox Code Playgroud)Wrap the ffmpeg process in a php file with exec. Save the uploaded file to db and give it an id. Call the encode function after a user uploads file. As soon as the encode function starts, update the db to reflect that the file was "picked". First run the ffmpeg info on the file to see if it is fine. Then encode the file and after it is done, update db flag to "done".
该过程完成后,您可以调用另一个函数向用户发送电子邮件、推文等,表明编码已完成。