Php-ffmpeg: Get FFMpeg\Exception\RuntimeException: Encoding failed after save()

Created on 15 May 2016  路  2Comments  路  Source: PHP-FFMpeg/PHP-FFMpeg

| Q | A |
| --- | --- |
| Bug? | no |
| New Feature? | no |
| Version Used | ~0.5 |
| FFmpeg Version | FFmpeg 3.0 |
| OS | OS X El Capitan 10.11.4 |

Actual Behavior

I'm using phpunit to run some tests, now all tests run OK except when I try to save() a video. FFMpeg works fine for me, but this library adds some additional code behind the scene that probably causes my code to fail.

Expected Behavior

I'm simply trying to save a video file, I haven't applied any filters yet.

Steps to Reproduce

This is the code that produces the error:

$ffmpeg = FFMpeg::create();
$video = $ffmpeg->open('originals/clip1.MOV');
$ffmpegVideo->save(new X264(), 'video_1.mp4')

This is the error I get from the exception thrown in the CLI.

MyProgramTests\ClipTest::testVideoExport
  FFMpeg\Exception\RuntimeException: Encoding failed

  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php:168
  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/includes/Video.php:61
  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/tests/ClipTest.php:126
  phar:///Applications/XAMPP/xamppfiles/bin/phpunit/phpunit/TextUI/Command.php:179
  phar:///Applications/XAMPP/xamppfiles/bin/phpunit/phpunit/TextUI/Command.php:132

  Caused by
  Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command '/usr/local/bin/ffmpeg' '-y' '-i' '/Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/tests/clips/originals/clip1.MOV' '-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' '/var/folders/x6/pkc00nd50xg9z8y4y35q69vc0000gn/T/ffmpeg-passes57388c760dcfd4oj3d/pass-57388c760ddf5' '/Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/tests/clips/clip_trip/video_1.mp4'

  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100
  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:72
  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php:209
  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php:137
  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php:158
  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/includes/Video.php:61
  /Applications/mampstack-5.4.17-0/apache2/htdocs/MyProgram/tests/ClipTest.php:126
  phar:///Applications/XAMPP/xamppfiles/bin/phpunit/phpunit/TextUI/Command.php:179
  phar:///Applications/XAMPP/xamppfiles/bin/phpunit/phpunit/TextUI/Command.php:132

Possible Solution

When I run the same command inside the terminall I get this specific error:
Unknown encoder 'libx264'
So I assume I'm missing libx264. But how can I get it?

bug question

Most helpful comment

hi @shillo92

I got the same error.

I resolved it in below code.

$video->save(new FFMpeg\Format\Video\X264('libmp3lame', 'libx264'), 'clip1.mp4');

Please consider this url:

http://stackoverflow.com/questions/29253498/php-ffmpeg-unknown-encoder-libfaac-on-windows

All 2 comments

hi @shillo92

I got the same error.

I resolved it in below code.

$video->save(new FFMpeg\Format\Video\X264('libmp3lame', 'libx264'), 'clip1.mp4');

Please consider this url:

http://stackoverflow.com/questions/29253498/php-ffmpeg-unknown-encoder-libfaac-on-windows

Hi,

I know this is a long time ago, but in case somebody encounters the same issue.

Instead of using

 `$ffmpegVideo->save(new X264(), 'video_1.mp4');`

I used either of the 2 and it works.

`$ffmpegVideo->save(new FFMpeg\Format\Video\WMV(), 'video_1.wmv');`

or

`$ffmpegVideo->save(new FFMpeg\Format\Video\WebM(), 'video_1.webm');`

Hope this helps someone.

Cheers!
Jesus
http://jesuserwinsuarez.com

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theDTD picture theDTD  路  4Comments

aminyazdanpanah picture aminyazdanpanah  路  6Comments

iki789 picture iki789  路  7Comments

jankal picture jankal  路  9Comments

sheikhasadmuneer picture sheikhasadmuneer  路  4Comments