簡體   English   中英

PHP-FFMpeg不轉換后(ffmpeg錯誤)

[英]AFTER PHP-FFMpeg not converting (error with ffmpeg)

我已經安裝了ffmpeg服務器端的所有依賴項,並對其進行了更新。 然后用Composer安裝PHP-FFMpeg。 測試ffmpeg已安裝ssh conexion。

root@host [/opt/ffmpeg]# ffmpeg
ffmpeg version N-81322-ge8b355a Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
configuration: --disable-yasm
libavutil      55. 28.100 / 55. 28.100
libavcodec     57. 51.100 / 57. 51.100
libavformat    57. 46.100 / 57. 46.100
libavdevice    57.  0.102 / 57.  0.102
libavfilter     6. 51.100 /  6. 51.100
libswscale      4.  1.100 /  4.  1.100
libswresample   2.  1.100 /  2.  1.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options]     outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

但是,當我嘗試使用php腳本轉換視頻文件時,會拋出一個非常長的錯誤。 PHP代碼:

<?PHP
include($_SERVER['DOCUMENT_ROOT']."/vendors/install/vendor/autoload.php");
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open($_SERVER['DOCUMENT_ROOT'].'/resources/uploads/96048/ffd3c5e349fa5745159deef163b5c253.wmv');
$video
       ->filters()
       ->synchronize();
$format = new FFMpeg\Format\Video\X264();
$format->on('progress', function ($video, $format, $percentage) {
    echo "$percentage % transcoded";});
$video
      ->save($format,$_SERVER['DOCUMENT_ROOT'].'/resources/uploads/96048/ffd3c5e349fa5745159deef163b5c253.mp4');
?>

顯示錯誤:

<b>Fatal error</b>:  Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffmpeg failed to execute command '/usr/local/bin/ffmpeg' '-y' '-i' '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.wmv' '-async' '1' '-metadata:s:v:0' 'start_time=0' '-threads' '12' '-vcodec' 'libx264' '-acodec' 'libfaac' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes57ad320a1b685j794u/pass-57ad320a1b716' '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.mp4'' in /home/user/working/vendors/install/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100↵Stack trace:↵#0 /home/user/working/vendors/install/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(72): Alchemy\BinaryDriver\ProcessRunner-&gt;doExecutionFailure(''/usr/bin/ffmpe...')↵#1 / in <b>/home/user/working/vendors/install/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php</b> on line <b>168</b><br />↵"

然后,我將向上顯示的基本代碼直接通過ssh運行。

'/usr/local/bin/ffmpeg' '-y' '-i' '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.wmv' '-async' '1' '-metadata:s:v:0' 'start_time=0' '-threads' '12' '-vcodec' 'libx264' '-acodec' 'libfaac' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes57ad320a1b685j794u/pass-57ad320a1b716' '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.mp4'

這是我得到的答復:

ffmpeg version N-81322-ge8b355a Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
  configuration: --disable-yasm
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 51.100 / 57. 51.100
  libavformat    57. 46.100 / 57. 46.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 51.100 /  6. 51.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, asf, from '/home/user/working/resources/uploads/23097/2efeb41a1a7085a1dbd469c4895ac23e.wmv':
  Metadata:
    SfOriginalFPS   : 299700
    WMFSDKVersion   : 11.0.6001.7000
    WMFSDKNeeded    : 0.0.0.0000
    comment         : Footage: Small World Productions, Inc; Tourism New Zealand | Producer: Gary F. Spradling | Music: Steve Ball
    title           : Wildlife in HD
    copyright       : © 2008 Microsoft Corporation
    IsVBR           : 0
    DeviceConformanceTemplate: AP@L3
  Duration: 00:00:30.09, start: 0.000000, bitrate: 6977 kb/s
    Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, 2 channels, fltp, 192 kb/s
    Stream #0:1(eng): Video: vc1 (Advanced) (WVC1 / 0x31435657), yuv420p, 1280x720, 5942 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc
Unknown encoder 'libx264'

我的問題是下一步該怎么做? 我已經浪費了三天時間來完成這項工作,這是我來的最遠的一次。 如何測試libx264是否已核心安裝? 如果未完全安裝它,該如何重新安裝或使其工作?

經過一些修改

我使用了已經安裝的ffmpeg,並刪除了一些命令(默認情況下相同),而這次我僅使用了命令行。

要求

'/home/user/working/vendors/install/ffmpeg-git-20160813-64bit-static/ffmpeg' '-y' '-i' '/home/user/working/resources/uploads/96048/ffd3c5e349fa5745159deef163b5c253.wmv' '-async' '1' '-metadata:s:v:0' 'start_time=0' '-vcodec' 'libx264' '-c:a' 'aac' '-b:v' '1000k' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes57b053ce14a12ljm8a/pass-57b053ce14ad3' '/home/user/working/resources/uploads/96048/ffd3c5e349fa5745159deef163b5c253.mp4'

新結果:

ffmpeg version N-81328-gceab04f-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-1) 20160803
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libmfx --enable-libzimg --cc=gcc-5
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 51.102 / 57. 51.102
  libavformat    57. 46.101 / 57. 46.101
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 51.100 /  6. 51.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, asf, from '/home/user/working/resources/uploads/96048/ffd3c5e349fa5745159deef163b5c253.wmv':
  Metadata:
    SfOriginalFPS   : 299700
    WMFSDKVersion   : 11.0.6001.7000
    WMFSDKNeeded    : 0.0.0.0000
    comment         : Footage: Small World Productions, Inc; Tourism New Zealand | Producer: Gary F. Spradling | Music: Steve Ball
    title           : Wildlife in HD
    copyright       : © 2008 Microsoft Corporation
    IsVBR           : 0
    DeviceConformanceTemplate: AP@L3
  Duration: 00:00:30.09, start: 0.000000, bitrate: 6977 kb/s
    Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, 2 channels, fltp, 192 kb/s
    Stream #0:1(eng): Video: vc1 (Advanced) (WVC1 / 0x31435657), yuv420p, 1280x720, 5942 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc
-async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.100000:first_pts=0.
[libx264 @ 0x442f5c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x442f5c0] ratecontrol_init: can't open stats file
Output #0, mp4, to '/home/user/working/resources/uploads/96048/ffd3c5e349fa5745159deef163b5c253.mp4':
  Metadata:
    SfOriginalFPS   : 299700
    WMFSDKVersion   : 11.0.6001.7000
    WMFSDKNeeded    : 0.0.0.0000
    comment         : Footage: Small World Productions, Inc; Tourism New Zealand | Producer: Gary F. Spradling | Music: Steve Ball
    title           : Wildlife in HD
    copyright       : © 2008 Microsoft Corporation
    IsVBR           : 0
    DeviceConformanceTemplate: AP@L3
    Stream #0:0(eng): Unknown: none
    Metadata:
      start_time      : 0
      encoder         : Lavc57.51.102 libx264
    Stream #0:1(eng): Unknown: none
    Metadata:
      encoder         : Lavc57.51.102 aac
Stream mapping:
  Stream #0:1 -> #0:0 (vc1 (native) -> h264 (libx264))
  Stream #0:0 -> #0:1 (wmav2 (native) -> aac (native))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

不支持x264

您的ffmpeg沒有經過編譯以支持通過libx264編碼:在配置行中缺少--enable-gpl --enable-libx264 最簡單的解決方法是下載已編譯的ffmpeg二進制文件 ,然后將您的腳本指向該文件。

其他的東西

您的ffmpeg具有--disable-yasm 這不好,會使事情變慢。

您的命令是一團糟,看起來像2006年一樣。您應該使用x264編碼預設,而不是嘗試聲明大量選項。 刪除-refs-coder-sc_threshold-flags +loop-me_range-subq-i_qfactor-qcomp-qdiff-trellis因為默認情況下會自動處理它們。

最好允許此編碼器自動選擇適當的線程數,因此請刪除-threads 12

有傳言說將從FFmpeg中刪除libfaac支持。 您的命令使用-acodec libfaac但是您的ffmpeg尚未編譯為支持它。 還有更好的選擇,例如libfdk_aac或本地FFmpeg AAC編碼器( -c:a aac )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM