protonemedia / laravel-ffmpeg

This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.
https://protone.media/en/blog/how-to-use-ffmpeg-in-your-laravel-projects
MIT License
1.66k stars 194 forks source link

Unable to load FFMpeg, Laravel 8, Ubuntu #351

Closed Demiurgich closed 3 years ago

Demiurgich commented 3 years ago

Hello,

I'm trying to use FFMPEG. Problem on local laptop with Ubuntu 20.04.

FFMPEG is installed on system. I can convert video in terminal using ffmpeg. which ffmpeg gives /usr/bin/ffmpeg

I use Laravel 8 and Sail.

Protonemedia/laravel-ffmpeg is installed using sail composer require pbmedia/laravel-ffmpeg

.env file contains FFMPEG_BINARIES=/usr/bin/ffmpeg FFPROBE_BINARIES=/usr/bin/ffprobe

laravel-ffmpeg.php contains ` 'ffmpeg' => [ 'binaries' => env('FFMPEG_BINARIES', '/usr/bin/ffmpeg'), 'threads' => 12, ],

'ffprobe' => [
    'binaries' => env('FFPROBE_BINARIES', '/usr/bin/ffprobe'),
],

`

config/app.php file contains ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider::class, in providers and 'FFMpeg' => ProtoneMedia\LaravelFFMpeg\Support\FFMpeg::class, in aliases.

Controller file is using FFMPEG: ` use ProtoneMedia\LaravelFFMpeg\Support\FFMpeg; use FFMpeg\Coordinate\Dimension; use FFMpeg\Format\Video\X264;

class ConvertVideoForStreaming implements ShouldQueue { public function handle() { $lowBitrateFormat = (new X264)->setKiloBitrate(500); $midBitrateFormat = (new X264)->setKiloBitrate(1500); $highBitrateFormat = (new X264)->setKiloBitrate(3000);

    FFMpeg::open($this->profileVideo->file)
    ->exportForHLS()
    ->toDisk('streamable_videos')
    ->addFormat($lowBitrateFormat)
    ->addFormat($midBitrateFormat)
    ->addFormat($highBitrateFormat)
    ->save($this->profileVideo->id . '.mp4');

}

} `

The error appears in FFMpeg::open($this->profileVideo->file) line.

The error is: FFMpeg\Exception\ExecutableNotFoundException Unable to load FFMpeg

Help me please to handle it out.

pascalbaljet commented 3 years ago

If you’re using Sail, be sure to install FFMpeg within the container.

Demiurgich commented 3 years ago

Thank you!

What I did: I published sail sail artisan sail:publish. Then I edited Dockerfile: added lines COPY /usr/bin/ffmpeg /usr/bin/ffmpeg and COPY /usr/bin/ffprobe /usr/bin/ffprobe. Now every time I run Docker those two files are copied to docker and ffmpeg works.

Thanks again!

fpolli commented 2 years ago

I have the same issue, and I tried the above solution, but it does not work. When I run sail build I get the following:

` => CACHED [ 9/13] COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf 0.0s => CACHED [10/13] COPY php.ini /etc/php/8.1/cli/conf.d/99-sail.ini 0.0s => CACHED [11/13] RUN chmod +x /usr/local/bin/start-container 0.0s => ERROR [12/13] COPY /usr/local/bin/ffmpeg /usr/bin/ffmpeg 0.0s => ERROR [13/13] COPY /usr/local/bin/ffprobe /usr/bin/ffprobe 0.0s

[12/13] COPY /usr/local/bin/ffmpeg /usr/bin/ffmpeg:


[13/13] COPY /usr/local/bin/ffprobe /usr/bin/ffprobe:

failed to compute cache key: "/usr/local/bin/ffprobe" not found: not found ERROR: Service 'laravel.test' failed to build : Build failed ` I have verified that the path to the two files is correct. I can run them in the terminal, but sail will not copy them into the docker container.

beiaduo commented 1 year ago

macbook test every thinking good, when i upload to ubuntu [2023-04-30 15:18:23] local.INFO: ffprobe running command '/usr/local/bin/ffprobe' '-help' '-loglevel' 'quiet'
[2023-04-30 15:18:23] local.INFO: ffprobe executed command successfully
[2023-04-30 15:18:23] local.INFO: ffprobe running command '/usr/local/bin/ffprobe' '/tmp/phpK1A3Cj' '-show_streams' '-print_format' 'json'
[2023-04-30 15:18:23] local.INFO: ffprobe executed command successfully
[2023-04-30 15:18:23] local.INFO: ffmpeg running command '/usr/local/bin/ffmpeg' '-y' '-ss' '00:00:10.00' '-i' '/tmp/phpK1A3Cj' '-vframes' '1' '-f' 'image2' '/www/wwwroot/ads.dopemv.com/storage/app/public/file/vjYS9ckPgYu4M2PojDaCSU5NshjSmTYRwz6CqV5s.mp4.jpg'
[2023-04-30 15:18:23] local.INFO: ffmpeg executed command successfully
[2023-04-30 15:18:23] local.ERROR: Unable to load FFProbe {"userId":1,"exception":"[object] (FFMpeg\Exception\ExecutableNotFoundException(code: 0): Unable to load FFProbe at /www/wwwroot/ads.dopemv.com/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Driver/FFProbeDriver.php:50) [stacktrace]

0 /www/wwwroot/ads.dopemv.com/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/FFProbe.php(220): FFMpeg\Driver\FFProbeDriver::create()

1 /www/wwwroot/ads.dopemv.com/app/Observers/FileObserver.php(41): FFMpeg\FFProbe::create()

2 /www/wwwroot/ads.dopemv.com/vendor/laravel/nova/src/Nova.php(259): App\Observers\FileObserver->App\Observers\{