| Q | A
| -------------- | ---
| Bug? | no
| New Feature? | no
| Version Used | Specific tag or commit sha
| FFmpeg Version | ffmpeg version 3.2-2+rpi1~xenial1.7
| OS | ubuntu Mate 16.04.2 LTS
How does PHP-FFMpeg behave at the moment?
Returns the following error when the webpage is accessed through the browser....
Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-ss' '00:00:10.00' '-i' 'test.mp4' '-vframes' '1' '-f' 'image2' 'frame.jpg' in /var/www/html/utilities/make_thumbnails/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100 Stack trace: #0 /var/www/html/utilities/make_thumbnails/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(72): Alchemy\BinaryDriver\ProcessRunner->doExecutionFailure(''/usr/bin/ffmpe...') #1 /var/www/html/utilities/make_thumbnails/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(209): Alchemy\BinaryDriver\ProcessRunner->run(Object(Symfony\Component\Process\Process), Object(SplObjectStorage), false) #2 /var/www/html/utilities/make_thumbnails/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(137): Alchemy\BinaryDriver\AbstractBinary->run(Object(Symfony\Component\Process\Process), false, NULL) #3 /var/www/html/utilities/make_thumbn in /var/www/html/utilities/make_thumbnails/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Frame.php on line 130
The funny thing is when I run the php file via commandline using:
php filename.php
it works...
I thought this might be a permissions thing so I made apache the owner but with the same result... Any ideas why it would work on commandline but not through the browser? I also tried executing the command via an exec statement in another php file with the same result. This further makes me think it is some kind of permissions thing but I am not sure what my next step is.
is the php safemode activated?
Hmmm... I am running PHP Version 7.0.15
No mention of a safemode in my php.ini file and after searching it appears to gone....
http://php.net/manual/en/features.safe-mode.php
This is as far as I can tell...
This is the php file I am using which is straight from the git here ....
` include 'vendor/autoload.php';
$ffmpeg = FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe',
'timeout' => 0, // The timeout for the underlying process
'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use
), @$logger);
$video = $ffmpeg->open('test.mp4');
$video
->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
->save('frame.jpg');
?>`
could I have the test.mp4 file? I'll try to reproduce it.
The php file? Sure... it is the code above though...so...
Nah, the file you want to process.
In the line $video = $ffmpeg->open('test.mp4'); you're opening test.mp4, and I want that file to check.
Oh.. sorry missed the mention of mp4.... hmmm... i am hesitant to give u the files just because it is of students. I am sure other mp4s will do the same. I can experiment and see. I wish it was a different file and i would shoot it over no problem. Ughhh...
Okey, I'm looking for another file I can reproduce it. 馃槈 And I'm watching out for something strange, too.
I have got this working finally!!! Ah... I feel so good.
I thought it was a permissions issue. The trouble with the above error (Fatal error: Uncaught Alchemy\BinaryDriv....) is that it is so nondescript. In experimenting it would return the same error if the save directory was not a valid path or some other php error. I caution those using this library to therefore not read to much into this message. It is possible that the installation is incorrect but also possible that there is some minor issue with your code itself. Possibly get all your code working perfectly up until the ffmpeg call and then you will have less of an area to debug.
For me, I was able to get this working by creating a usergroup with www-data(apache user) and myself... then I changed permissions for the folders I needed to read and write to. For me, I am so sick of the permissions BS in linux and I am not super concerned about security(which I am unclear how much of a risk this is anyway) but I just set this up for the www folder entirely. like so:
sudo chown -R me:me_and_www-data_usergroup /var/www
Glad you'd made it.
Possibly get all your code working perfectly up until the ffmpeg call and then you will have less of an area to debug.
Hmm... I think it isn't possible, because maybe we don't have access to a file ffmpeg may have access to. The exception is thrown when the exit status is not 0(0 = successful exit/not an error).
@romainneutron you may want to close this?
I will @jens1o.
@totomtornado www-data needs a write access to your destination folder. He is the owner of the FFMPEG process and therefore needs to be able to write the generated file. ;)
sudo chown -R
Thanks for the hint :)
I am getting the same error even after the change ownership .
@sarvap-praharanayuthan
Can you suggest "Sudo chown -R" in which directory
@Romain I am suffering from same problem.
I have command php artisan encode which helps to convert to files. I have given write access to destination folder as well. Still , I am having same problem.
If i run ffmpeg -i input.mp4 output.avi directly. it works fine .
I am getting the same error even after the change ownership .
@sarvap-praharanayuthan
Can you suggest "Sudo chown -R" in which directory
You will have to own the directory where you're trying to save the output.avi file.
Supposedly if your output.avi file is to be stored in /var/www/mysite.com/assets,
chown -R www-data:www-data /var/www/mysite.com or /var/www/mysite.com/assets will help you. Owning mysite.com directory will be helpful for all related operations not restricted to ffmpeg.
Most helpful comment
You will have to own the directory where you're trying to save the
output.avifile.Supposedly if your
output.avifile is to be stored in/var/www/mysite.com/assets,chown -R www-data:www-data /var/www/mysite.comor/var/www/mysite.com/assetswill help you. Owningmysite.comdirectory will be helpful for all related operations not restricted to ffmpeg.