duankan8739 2017-08-25 19:39
浏览 83

ffmpeg从终端工作,但不是由PHP脚本

I have to get the thumbnail image of video i am using the ffmpeg. On my server i run the ffmpeg command from ssh then it is working but from the php exec function it is not working it gives the error /usr/bin/ffmpeg : no such file or dirctory but the ffmpeg is installed on this location usr/bin/ffmpeg. my source code is:

$ffmpeg = '/usr/bin/ffmpeg';

$videoname = 'myvideo.mp4';

$video = $_SERVER['DOCUMENT_ROOT'].'/uploads/videos/'.$videoname;

$image = $_SERVER['DOCUMENT_ROOT'].'/uploads/thumbs/thumb.jpg';

$second = 1;

$cmd = "$ffmpeg -i $video -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $image 2>&1";

exec($cmd);

Please provide any solution.

  • 写回答

2条回答 默认 最新

  • duanshang7007 2017-08-25 20:03
    关注

    Update you code with this one you will be good to go.

    `$ffmpeg = '/usr/bin/ffmpeg';

    $videoname = 'myvideo.mp4';

    $video = $_SERVER['DOCUMENT_ROOT'].'/uploads/videos/'.$videoname;

    $image = $_SERVER['DOCUMENT_ROOT'].'/uploads/thumbs/thumb.jpg';

    $second = 1;

    $cmd = "$ffmpeg -i '".$video."' -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg '".$image."' 2>&1"; echo $cmd; exec($cmd);`

    Sometimes exec() function miss behaves due to missing quotes around variables.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度