Php-ffmpeg: Can't encode video Fatal error

Created on 1 Jun 2018  路  7Comments  路  Source: PHP-FFMpeg/PHP-FFMpeg

| Q | A
| -------------- | ---
| Bug? | Yes
| New Feature? | no
| Version Used | v0.11.1
| FFmpeg Version | N-90920-ge07b1913fc
| OS | Windows 10 x64

Actual Behavior

How does PHP-FFMpeg behave at the moment?
I'm trying to encode an video however I keep getting this fatal error:

Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command C:\ffmpeg\bin\ffmpeg.EXE -y -i C:\wamp64\www\memevibe\vid.mp4 -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 256k -ac 2 -pass 1 -passlogfile "C:\WINDOWS\TEMP\ffmpeg-passes5b1135d42c19c9th7l/pass-5b1135d42c4bc" C:\wamp64\www\memevibe\vid21.mp4 in C:\wamp64\www\memevibe\vendor\alchemy\binary-driver\src\Alchemy\BinaryDriver\ProcessRunner.php:100
Stack trace:

0 C:\wamp64\www\memevibe\vendor\alchemy\binary-driver\src\Alchemy\BinaryDriver\ProcessRunner.php(72): Alchemy\BinaryDriver\ProcessRunner->doExecutionFailure('C:\ffmpeg\bin\f...')

1 C:\wamp64\www\memevibe\vendor\alchemy\binary-driver\src\Alchemy\BinaryDriver\AbstractBinary.php(209): Alchemy\BinaryDriver\ProcessRunner->run(Object(Symfony\Component\Process\Process), Object(SplObjectStorage), false)

2 C:\wamp64\www\memevibe\vendor\alchemy\binar in C:\wamp64\www\memevibe\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Media\Video.php on line 109

Here is my code which is really basic.

$ffmpeg = \FFMpeg\FFMpeg::create();
$video = $ffmpeg->open($video_path);
$format = new \FFMpeg\Format\Video\X264();

$video->save($format, "C:\\wamp64\\www\\web\\vid21.mp4");

$video->save(...) is throwing the error

I also tried catching exceptions but failed to.

try{
  ...
}catch(\Alchemy\BinaryDriver\ConfigurationInterface $e){
  echo $e->getMessage();
}catch(\Alchemy\BinaryDriver\Exception\ExecutionFailureException $e){
  echo $e->getMessage();
}catch(\FFMpeg\Driver\FFProbeDriver $e){
  echo $e->getMessage();
}
bug help wanted

Most helpful comment

Executing:
ffmpeg.EXE -y -i C:\wamp64\www\memevibe\vid.mp4 -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 256k -ac 2 C:\wamp64\www\memevibe\vid1.mp4

leads to an error saying Unknown encoder 'libfaac'

Replacing libfaac with aac seemed to work.

I set the audio codec using the library with setAudioCodec('aac'):


$format = new \FFMpeg\Format\Video\X264();
$format->setAudioCodec("aac");

Since audio codec libfaac has been removed from ffmpeg, I think instantiating FFMpeg\Format\Video\ should default to using aac codec for audio.

All 7 comments

Could you please execute the command C:\ffmpeg\bin\ffmpeg.EXE -y -i C:\wamp64\www\memevibe\vid.mp4 -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 256k -ac 2 using cmd and report the output?

Executing:
ffmpeg.EXE -y -i C:\wamp64\www\memevibe\vid.mp4 -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 256k -ac 2 C:\wamp64\www\memevibe\vid1.mp4

leads to an error saying Unknown encoder 'libfaac'

Replacing libfaac with aac seemed to work.

I set the audio codec using the library with setAudioCodec('aac'):


$format = new \FFMpeg\Format\Video\X264();
$format->setAudioCodec("aac");

Since audio codec libfaac has been removed from ffmpeg, I think instantiating FFMpeg\Format\Video\ should default to using aac codec for audio.

Hmm. Maybe change this to 'aac'

@iki789 Oh, good catch. Would you mind testing whether it works and then file a pr to change it?

For me only aac works

Does somebody wants to create a PR? :)

Was this page helpful?
0 / 5 - 0 ratings