在背景中转换视频php ffmpeg? [英] Convert videos in background php ffmpeg?

查看:184
本文介绍了在背景中转换视频php ffmpeg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用exec(),FFMPEG php转换视频。我想在后台运行脚本。我该怎么做?

I would like to convert videos with exec(), FFMPEG php. I would like to run the script in background. How can I do that?

/*** convert video to flash ***/ 

$v = date('H-i-s');

//   exec("ffmpeg -i uploaded_files/770530705510e88ec723a3-20130111_1221_43.avi -ar 22050 -ab 32 -f flv -s 320x240 flash/".microtime()."video.flv 1> flash/".$v."_block.txt 2>&1");

$cmd = 'ffmpeg -i uploaded_files/770530705510e88ec723a3-20130111_1221_43.avi -ar 22050 -ab 32 -f flv -s 320x240 flash/'.microtime().'.flv';

$outputfile = $v.'.txt.';
$pidfile = $v.'_id.txt.';

      exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile));

这是我的代码,但不要做任何事情。
我想用php运行脚本,但是我不想等待http加载时间,直到脚本完成...

This is my code, but don't do anything. I would like to run the script with the php, but I don't want to wait the http loading time until the script is finished...

或者如何用exec()运行something.php? ?如果我可以运行php,很容易我做所有我需要的。 (linux debian,apache2,php5)

OR how can I run something.php with exec(); ? If I could run php that was easy me to make all what I needed. (linux debian, apache2, php5)

推荐答案

最好的方法是将作业添加到队列中,让服务器处理ffmpeg以异步方式转换。

The best way is to add a job to a queue and let the server handle the ffmpeg conversion in asynchronous way.

用户必须手动重新检查服务器是否已经完成该作业。

The users has to manually recheck if the server has already finished the job.

你必须这样做:


  1. 创建一个队列数据库表。

  2. 如果新的ffmpeg转换应该在队列表中添加一个作业。

  3. 在服务器上添加一个自动寻找新作业并执行ffmpeg转换的cronjob。 此处有更多细节

  4. 当cronjob完成转换,然后标记作业完成,删除它或任何。

  1. Create a queue database table.
  2. If a new ffmpeg conversion should be done add a job to the queue table.
  3. On the server add a cronjob which automatically looks for new jobs and executes your ffmpeg conversion. More details here.
  4. When the cronjob has finished the conversion then mark the job as done, delete it, or whatever.

这篇关于在背景中转换视频php ffmpeg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆