Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP和FFmpeg:在终端上工作,但在shell_exec中FFmpeg错误_Php_Ffmpeg_Shell Exec - Fatal编程技术网

PHP和FFmpeg:在终端上工作,但在shell_exec中FFmpeg错误

PHP和FFmpeg:在终端上工作,但在shell_exec中FFmpeg错误,php,ffmpeg,shell-exec,Php,Ffmpeg,Shell Exec,我面临一个我无法解决的问题 我尝试使用ffmpeg工具转换视频。当我将命令粘贴到服务器终端(ssh root)上时,它可以正常工作。但是,当我尝试使用shell\u exec在PHP脚本中执行时,它返回错误“error while opening encoder…” 以下是我使用的命令: ffmpeg -y -i VIDEOIN.mov -preset medium -strict -2 -c:v libx264 -b:v 1000k -pass 1 -f mp4 VIDEOOUT.mp4 &l

我面临一个我无法解决的问题

我尝试使用
ffmpeg
工具转换视频。当我将命令粘贴到服务器终端(ssh root)上时,它可以正常工作。但是,当我尝试使用
shell\u exec
在PHP脚本中执行时,它返回错误“error while opening encoder…”

以下是我使用的命令:

ffmpeg -y -i VIDEOIN.mov -preset medium -strict -2 -c:v libx264 -b:v 1000k -pass 1 -f mp4 VIDEOOUT.mp4 </dev/null 1>logfile.txt 2>&1 &
编辑1:


我用最新版本编译了ffmpeg,但问题仍然存在

我在Synology服务器上得到了相同的pb。这是对
/usr/syno/etc/codec/activation.conf
的读取权限,从PHP调用ffmpeg时不授予该权限

响应位于/var/log/messages日志文件中:

Jan 25 19:00:11 MySpher-Serv synocodectool: G1HttpSend.cpp:198 SaveResponseToFile failed
Jan 25 19:00:11 MySpher-Serv synocodectool: G1Licence.cpp:40 Failed to read file [/usr/syno/etc/codec/activation.conf]
Jan 25 19:00:11 MySpher-Serv synocodectool: G1Licence.cpp:66 read json file [/usr/syno/etc/codec/activation.conf] error
Jan 25 19:00:11 MySpher-Serv synocodectool: SYNOCodecPatentG1.cpp:223 ValidateG1Licence failed
一个简单的
chmod 777/usr/syno/etc/codec/activation.conf(在子目录中)确实解决了这个问题

ffmpeg version 1.0.8 Copyright (c) 2000-2013 the FFmpeg developers
built on Sep 12 2013 11:57:09 with gcc 4.7 (Debian 4.7.2-5)
configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libfdk-aac --enable-libdc1394 --disable-altivec --dis  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, matroska,webm, from 'videos/18352678af96ecb5/origin.webm':
  Metadata:
    creation_time   : 2010-05-20 08:21:12
  Duration: 00:00:32.48, start: 0.000000, bitrate: 533 kb/s
    Stream #0:0(eng): Video: vp8, yuv420p, 640x360, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, s16 (default)
[libx264 @ 0x19c05a0] using SAR=1/1
[libx264 @ 0x19c05a0] using cpu capabilities: MMX2 SSE2Fast SSEMisalign LZCNT
[libx264 @ 0x19c05a0] ratecontrol_init: can't open stats file
Output #0, mp4, to 'videos/18352678af96ecb5/video.mp4':
    Stream #0:0(eng): Video: h264, yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, pass 1,     90k tbn, 25 tbc (default)
    Stream #0:1(eng): Audio: none, 44100 Hz, mono, s16, 128 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 -> libx264)
  Stream #0:1 -> #0:1 (vorbis -> libfaac)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as     bit_rate, rate, width or height
Jan 25 19:00:11 MySpher-Serv synocodectool: G1HttpSend.cpp:198 SaveResponseToFile failed
Jan 25 19:00:11 MySpher-Serv synocodectool: G1Licence.cpp:40 Failed to read file [/usr/syno/etc/codec/activation.conf]
Jan 25 19:00:11 MySpher-Serv synocodectool: G1Licence.cpp:66 read json file [/usr/syno/etc/codec/activation.conf] error
Jan 25 19:00:11 MySpher-Serv synocodectool: SYNOCodecPatentG1.cpp:223 ValidateG1Licence failed