| Q | A
| -------------- | ---
| Bug? | probably
| New Feature? | no
| Version Used | Last version
| FFmpeg Version | FFmpeg
| OS | Linux
I am working with Laravel 5.3
In my localhost works fine
_When I uploaded to my shared host fails_
My binaries has +x permissions
Encoding failed in file
/php-ffmpeg/src/FFMpeg/Media/Video.php
line : 178
In my server, I have my files in my web dir
` $ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/home3/myuser/public_html/myproject/binvideos/ffmpeg',
'ffprobe.binaries' => '/home3/myuser/public_html/myproject/binvideos/ffprobe',
'timeout' => 9800, // The timeout for the underlying process
'ffmpeg.threads' => 12 // The number of threads that FFMpeg should use
]);
$videoCodec = $ffmpeg->open(public_path("uploads/targets/$videoName"));
$format = new X264();
$format->setAudioCodec('aac','libmp3lame');
$videoCodec->save($format,$newVideoPath);
`
Please check wether the php executing process has also these permissions and they are not exclusive to the root user.
Yes is writing the file because it appears in the directory I wrote but for some reason it fails when is encoding, or at least that said the issue.
FFMpeg\Media\Video->save(Object(FFMpeg\Format\Video\X264), '/home3/myuser...')
How can I check those because in local I didn't need it
Check to which user the directory owns(and maybe overwrite it to the php user)
My web user is the same as the owner in my web dir and the dir where I have the binaries.
I remember you, I have binaries inside my web dir because I can not put them in usr/bin or usr/local/bin
Could you post the exact error message? Usally, there is a command inside the exception message. That's interesting
This is all I have, I tried get something more but is all.
{$e->getMessage()},
{$e->getFile()},
{$e->getLine()},
{$e->getCode()}:::::::
{$e->getTraceAsString()}
[2017-04-07 14:36:23] local.INFO: Run time exception :::::::Encoding failed,
whoami: myuser,
/home3/myuser/public_html/spiff/vendor/phpffmpeg/phpffmpeg/src/FFMpeg/Media/Video.php,
Line 178,
Code 0:::::::
#0 /home3/myuser/public_html/spiff/app/Http/Controllers/TargetsController.php(134): FFMpeg\Media\Video->save(Object(FFMpeg\Format\Video\X264), '/home3/myproject...')
But this can't be the full stacktrace... Also, there should be a exception included("previous")
Oh sure here I had
exception 'Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffmpeg failed to execute command '/home3/myuser/public_html/spiff/binvideos/ffmpeg' '-y' '-i' '/home3/myuser/public_html/spiff/public/uploads/targets/video_EdFcBkLPmCfuWQwy6PMa.mp4' '-threads' '12' '-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' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes58e7cb31b2f0dwczeb/pass-58e7cb31b2fcf' '/home3/myuser/public_html/spiff/public/uploads/targets/export_ODxmwE3cgKmRGN6lKn0H.mp4'' in /home3/myuser/public_html/spiff/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100
okey, could you try to execute the command on your own(and show us the output)?
'/home3/myuser/public_html/spiff/binvideos/ffmpeg' '-y' '-i' '/home3/myuser/public_html/spiff/public/uploads/targets/video_EdFcBkLPmCfuWQwy6PMa.mp4' '-threads' '12' '-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' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes58e7cb31b2f0dwczeb/pass-58e7cb31b2fcf' '/home3/myuser/public_html/spiff/public/uploads/targets/export_ODxmwE3cgKmRGN6lKn0H.mp4'
I got this :
I checked it and the resource already exists
ffmpeg version 3.2.2-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.1 (Debian 5.4.1-4) 20161202
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home3/inmersy1/public_html/spiff/public/uploads/targets/video_EdFcBkLPmCfuWQwy6PMa.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2012-04-24T23:55:03.000000Z
encoder : Lavf53.24.0
Duration: 00:00:11.85, start: 0.000000, bitrate: 944 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 596x336 [SAR 1:1 DAR 149:84], 941 kb/s, 29.97 fps, 29.97 tbr, 2997 tbn, 59.94 tbc (default)
Metadata:
creation_time : 2012-04-24T23:55:03.000000Z
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Error while opening decoder for input stream #0:0 : Resource temporarily unavailable
Well, that's a ffmpeg problem(and I don't know how to fix it; sorry!) and not one with the library. Maybe try a different file? And please update your ffmpeg, since it is outdated.
Ok I will try it. Is weird because in my local environment is working. I really appreciate your help. Thanks
Please let us tuned.
After some research, most people suggested that you're only using one thread(when your server forces code to be single-threaded), do so by replacing
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/home3/myuser/public_html/myproject/binvideos/ffmpeg',
'ffprobe.binaries' => '/home3/myuser/public_html/myproject/binvideos/ffprobe',
'timeout' => 9800, // The timeout for the underlying process
'ffmpeg.threads' => 12 // The number of threads that FFMpeg should use
]);
to this:
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/home3/myuser/public_html/myproject/binvideos/ffmpeg',
'ffprobe.binaries' => '/home3/myuser/public_html/myproject/binvideos/ffprobe',
'timeout' => 9800, // The timeout for the underlying process
'ffmpeg.threads' => 1 // The number of threads that FFMpeg should use
]);
let me know wether this works for you.
Hi, tried with one thread and I got this error. My Binaries works are the same as I use in local and works and are the lasts version, also the videos I test have no problem, in my local works fine. any idea?.
Alchemy\BinaryDriver\Exception\ExecutionFailureException' with message 'ffmpeg failed to execute command '/home3/inmersy1/public_html/spiff/binvideos/ffmpeg' '-y' '-i' '/home3/inmersy1/public_html/spiff/public/uploads/targets/video_Noq6Vq36N7uRIexbGWrL.mp4' '-threads' '1' '-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' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes58eb90f55173apy834/pass-58eb90f5517f1' '/home3/inmersy1/public_html/spiff/public/uploads/targets/export_CY8qvAXM1XocpdXeWDte.mp4'' in /home3/inmersy1/public_html/spiff/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100
I don't know to be honest. Let us know when you found something out, it could be useful for others, too.
SOLVED I guess
I already solved just changing this line
$format->setAudioCodec('aac','libmp3lame');
by this one
$format->setAudioCodec('libmp3lame');
Can I not add two codecs? or is in array param?
No, you can't do that(it's not possible by ffmpeg, therefore not by this lib). If you want to do 2 exports, you need to create two formats and save both.
Oh, so, at end it was my typo I really feel like a fool, sorry to waste your time dude I did not notice
Hey, no problem. We'll update the implementation and check that this won't happen ever again. It's fine. You'd actually found a bug(we should check that).