Php-ffmpeg: PHP Fatal error: Uncaught exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException'

Created on 8 Jun 2019  路  4Comments  路  Source: PHP-FFMpeg/PHP-FFMpeg

We are getting issue in cutting up a video. Issue is ffmpeg works perfectly for a single cut request from browser but for multiple cut requests from browser (multiple users using the system) creates this except for atleast one process or all.

`PHP Fatal error: Uncaught exception 'AlchemyBinaryDriverExceptionExecutionFailureException' with message 'ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i' '/var/www/html/videosity/content/videosity-org-45/courses/455cf62cd1f12dc/video/v0.1/455cf62cd1f12dc.mp4' '-ss' '00:00:24.00' '-t' '00:05:24.00' '-vcodec' 'libx264' '-acodec' 'aac' '-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' '-strict' '-2' '-b:a' '128k' '-pass' '2' '/var/www/html/videosity/content/videosity-org-45/courses/455cf62cd1f12dc/video/topics/v0.1/455cf62cd1f12dc1559643263905.mp4'' in /var/www/html/videosity/designer/server/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:101
Stack trace:

0 /var/www/html/videosity/designer/server/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(74): AlchemyBinaryDriverProcessRunner->doExecutionFailure(''/usr/bin/ffmpe...')

1 /var/www/html/videos in /var/www/html/videosity/designer/server/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php on line 169`

Here is our cut function

`
function clipVideo($startPoint, $duration, $inputPath, $outputPath){

$ffmpeg = FFMpeg\FFMpeg::create(array(
    'ffmpeg.binaries' => '/usr/bin/ffmpeg',
    'ffprobe.binaries' => '/usr/bin/ffprobe',
    'timeout'          => 7200, // The timeout for the underlying process
    'ffmpeg.threads'   => 12
));

$format = new FFMpeg\Format\Video\X264();

$video = $ffmpeg->open($inputPath);

$video->filters()->clip(FFMpeg\Coordinate\TimeCode::fromSeconds($startPoint), FFMpeg\Coordinate\TimeCode::fromSeconds($duration));

 $video->save($format, $outputPath);

}
`

Tried running multiple ffmpeg commands in parallel from server and it works perfectly.
Also tried running this clipVideo function simultaneously from different terminal sessions and it works perfectly.
Issue occurs only when multiple requests comes from browsers. For single request it works perfectly irrespective of video length.
Permissions are also set to www-data (for php).

Most helpful comment

Hey man you are missing the streams of video and audio in the format, just try once by adding the audio and video streams in format field. Example code

new \FFMpeg\Format\Video\X264('libmp3lame', 'libx264')

All 4 comments

To be honest: I've got no clue, too. Maybe the user may only open one external pipe(i.e. a terminal)?

Thanks @jens1o for looking into it.
I didn't get what you mean by 'Maybe the user may only open one external pipe(i.e. a terminal)?'

Hey man you are missing the streams of video and audio in the format, just try once by adding the audio and video streams in format field. Example code

new \FFMpeg\Format\Video\X264('libmp3lame', 'libx264')

Hey..!!
$ffmpeg = FFMpeg\FFMpeg::create(array( 'ffmpeg.binaries' => '/usr/local/bin/ffmpeg', 'ffprobe.binaries' => '/usr/local/bin/ffprobe', 'timeout' => 3600, // The timeout for the underlying process 'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use ));

This code worked for me.

Was this page helpful?
0 / 5 - 0 ratings