简体   繁体   English

Laravel 4 - PHP-FFMpeg - 进展

[英]Laravel 4 - PHP-FFMpeg - progress

I am using PHP-FFmpeg with laravel to create encodes of the clips uploaded to the app ( php-ffmpeg github ). 我正在使用带有laravel的PHP-FFmpeg来创建上传到应用程序的剪辑的编码( php-ffmpeg github )。 The documentation says that transcoding progress can be monitored in realtime, by providing the 'progress' event callback. 文档说明通过提供'progress'事件回调,可以实时监控转码进度。

$video  = $ffmpeg->open($originaldir);

$format = new $format_class();

$format->on('progress', function ($video, $format, $percentage) {
            echo("$percentage % transcoded");
});

The function is written in the controller but, how can I get the the $percentage variable out of the closure and show it in the view? 该函数是在控制器中编写的,但是,如何从闭包中获取$百分比变量并在视图中显示它?

Update 更新

I have tried to use this package to store the $percentage var into a js variable, so I could access it in the view: https://github.com/laracasts/PHP-Vars-To-Js-Transformer , but it doesn't seem to work. 我试图使用这个包将$ percentage var存储到一个js变量中,所以我可以在视图中访问它: https//github.com/laracasts/PHP-Vars-To-Js-Transformer ,但它没有似乎工作。 This is what I've tried to do in the controller: 这是我在控制器中尝试做的事情:

JavaScript::put([
    'prog' => $percentage
]);

您需要将某个百分比 - 用户的会话,存储在某种类型的数据库中等 - 存储,并通过AJAX定期检索该值以显示给用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM