douya2007 2011-06-10 03:19
浏览 107
已采纳

如何设置进程以便在另一个进程之后执行?

I have a php video uploader script and at the end it initiates an ffmpeg script for the conversion of the uploaded file. It then inserts the video info into a mysql database and in the status field, a value of 0 since the file is being processed.

I was thinking that along with the linux ffmpeg command I could put a delayed process that executes a php file so that after the file is converted and the ffmpeg process is complete it executes the php file and that file has an update statement and can update the video entry in the mysql database under status to 1. To do that though I need to somehow pass the video id into the terminal so it can pass it to the php file...Anyone know how to do this?

$sql = 'INSERT INTO video (id, uploader, video_id, status) VALUES(?,?,?,?)';
$stmt3 =$conn->prepare($sql);
$result=$stmt3->execute(array($id,$username,$video_id,0));

$command = shell_exec('/usr/local/bin/ffmpeg -i /home/g/Desktop/'.$id2.' -acodec libfaac -aq 100 -vcodec libx264 -preset slow -crf 22 -threads 0 /home/g/Desktop/'.$id2.'.flv');
  • 写回答

1条回答 默认 最新

  • dongxu7121 2011-06-10 03:40
    关注

    Try this:

    $command = shell_exec('/usr/local/bin/ffmpeg -i /home/g/Desktop/'.$id2.'' .
        '-acodec libfaac -aq 100 -vcodec libx264 -preset slow -crf 22 -threads 0' .
        '/home/g/Desktop/'.$id2.'.flv && /usr/bin/php /home/g/bin/update_db.php ' . $id2);
    

    It says to execute '/usr/bin/php /home/g/bin/update_db.php ' . $id2 if the ffmpeg(1) command succeeds. (It might fail.)

    To try this at the shell: true && echo hi and false && echo hi.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器