FFMPEG在命令行运行但不是PHP [英] FFMPEG running in Command Line but not PHP

查看:192
本文介绍了FFMPEG在命令行运行但不是PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ffmpeg构建窗口来制作视频缩略图。该命令在命令行中运行良好,但不适用于PHP exec方法。正在使用PHP 5.2.11



这是命令。

 E:/ Documents and Settings / x / WINDOWS / ffmpeg-itsoffset -4 -vE:/ Program Files / Apache Software Foundation / Apache2.2 / htdocs / bs / files / videogal / c08c3d20eeb9083ed033577bd154cba6.flv-vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240E:/ Program Files / Apache Software Foundation / Apache2.2 / htdocs / bs / files / gallery / 8ff43b72b932d2a34e7a6733672ad4d6.jpg2>&$ 1 

有人可以帮忙。我检查了他们似乎很好的权限。 GD已安装。



错误msg是'E:/ Documents'不被识别为内部或外部命令,可操作的程序或批处理文件



在我的路径中使用正斜杠,除了转义双引号



PHP函数

  function ExtractThumb($ in,$ out)
{$ path = dbconf :: FFMPEG_PATH;
$ thumb_stdout;
$ errors;
$ retval = 0;
echo $ in;
//如果文件已经存在,请删除该文件
if(file_exists($ out)){unlink($ out); }

//使用ffmpeg从电影中生成一个缩略图
$ cmd =$ path -itsoffset -4 -i $ in -vcodec mjpeg -vframes 1 -an -f rawvideo - s 320x240 $ out 2>& 1;
echo $ cmd;

exec($ cmd,$ thumb_stdout,$ retval);

//排队处理
的错误if($ retval!= 0){$ errors [] =FFMPEG缩略图生成失败;

如果(!empty($ thumb_stdout))
{
foreach($ thumb_stdout as $ line)
{
echo $ line。 \\\
;
}
}

if(!empty($ errors))
{
foreach($ errors as $ error)
{
echo $ error。 \\\
;
}
}
}

$ in和$ out绝对路径这是我得到的

 版权所有(c)2000-2009 Fabrice Bellard等人配置:--extra-cflags = -fno-common --enable-memalign-hack --enable-pthreads --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-libtheora --enable-libspeex  - -enable-libfaac --enable-libgsm --enable-libx264 --enable-libschroedinger --enable-avisynth --enable-swscale --enable-gpl libavutil 49.12。 0 / 49.12。 0 libavcodec 52.10。 0 / 52.10。 0 libavformat 52.23。 1 / 52.23。 1 libavdevice 52. 1. 0 / 52. 1. 0 libswscale 0. 6. 1 / 0. 6. 1建于2009年1月13日02:57:09,gcc:4.2.4 822ae86a93810dade2843e822390d723.flv:没有这样的文件或目录


解决方案

  exec \E:\\Documents and Settings\\x\\WINDOWS\\ffmpeg\-i< inputfile>< options>< outfile>); 

这是我以前使用过的(授予我在LAMP堆栈中) :$ / $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ vframe 1 -s 100x56 -ss 3 -t 0.001。$ out;

您还可以考虑: http://ffmpeg-php.sourceforge.net/


I am using ffmpeg build for windows to make video thumbnails . The command works well in command line but not from PHP exec method. am using PHP 5.2.11

Here is the command.

"E:/Documents and Settings/x/WINDOWS/ffmpeg" -itsoffset -4 -v "E:/Program Files/Apache Software Foundation/Apache2.2/htdocs/bs/files/videogal/c08c3d20eeb9083ed033577bd154cba6.flv" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 "E:/Program Files/Apache Software Foundation/Apache2.2/htdocs/bs/files/gallery/8ff43b72b932d2a34e7a6733672ad4d6.jpg" 2>&1

Can somebody help. I checked the permissions they seem fine. GD is installed.

The error msg is 'E:/Documents' is not recognized as an internal or external command, operable program or batch file

Am using forward slashes in my paths except when escaping double quotes

The PHP function

function ExtractThumb($in, $out)
{$path=dbconf::FFMPEG_PATH;
    $thumb_stdout;
    $errors;
    $retval = 0;
 echo $in;
    // Delete the file if it already exists
    if (file_exists($out)) { unlink($out); }

    // Use ffmpeg to generate a thumbnail from the movie
    $cmd = "$path -itsoffset -4 -i $in -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 $out 2>&1";
   echo $cmd;

   exec($cmd, $thumb_stdout, $retval);

    // Queue up the error for processing
    if ($retval != 0) { $errors[] = "FFMPEG thumbnail generation failed"; }

    if (!empty($thumb_stdout))
    {
        foreach ($thumb_stdout as $line)
        {
            echo $line . "\n";
        }
    }

    if (!empty($errors))
    {
        foreach ($errors as $error)
        {
            echo $error . "\n";
        }
    }
}

funny enough if I run without the $in and $out absolute path this is what I get

Copyright (c) 2000-2009 Fabrice Bellard, et al. configuration: --extra-cflags=-fno-common --enable-memalign-hack --enable-pthreads --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libfaac --enable-libgsm --enable-libx264 --enable-libschroedinger --enable-avisynth --enable-swscale --enable-gpl libavutil 49.12. 0 / 49.12. 0 libavcodec 52.10. 0 / 52.10. 0 libavformat 52.23. 1 / 52.23. 1 libavdevice 52. 1. 0 / 52. 1. 0 libswscale 0. 6. 1 / 0. 6. 1 built on Jan 13 2009 02:57:09, gcc: 4.2.4 822ae86a93810dade2843e822390d723.flv: no such file or directory

解决方案

exec("\"E:\\Documents and Settings\\x\\WINDOWS\\ffmpeg\" -i <inputfile> <options> <outfile>");

Here's one of mine I've used in the past (granted I'm on a LAMP stack):

$cmd = "/usr/bin/ffmpeg -i ".$in." -y -an -sameq -vframes 1 -s 100x56 -ss 3 -t 0.001 ".$out;

You may also consider: http://ffmpeg-php.sourceforge.net/

这篇关于FFMPEG在命令行运行但不是PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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