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 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题