WillMaddicott
WillMaddicott

Reputation: 532

Laravel FFMpeg - Unable to load FFMpeg in file error

I'm trying to integrate FFMpeg into a Laravel project but am getting the error when I call the end point:

FFMpeg\Exception\ExecutableNotFoundException: Unable to load FFMpeg in file /Users/me/Desktop/video/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Driver/FFMpegDriver.php on line 55

What I've done:

brew install ffmpeg - installed FFMEG locally, can confirm that this works when using terminal

Fresh Laravel install composer create-project laravel/laravel example-app

Install php ffmpeg composer require php-ffmpeg/php-ffmpeg

install Laravel ffmpeg composer require pbmedia/laravel-ffmpeg

added FFMPEG to providers and aliases in app.php:

'providers' => [
    ...
    ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider::class,
    ...
];

'aliases' => [
    ...
    'FFMpeg' => ProtoneMedia\LaravelFFMpeg\Support\FFMpeg::class
    ...
];

and then my controller is

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use FFMpeg;

class VideoController extends Controller
{
    public function makeVideo()
    {

        FFMpeg::fromDisk('songs')
    ->open('yesterday.mp3')
    ->export()
    ->toDisk('converted_songs')
    ->inFormat(new \FFMpeg\Format\Audio\Aac)
    ->save('yesterday.aac');
        return "hello";
    }
}

which is the example they give on git. if I call the end point I get the above error. Has anyone got any ideas what's wrong or how to debug? The logs don't give me any more information!

Upvotes: 2

Views: 6345

Answers (2)

sykez
sykez

Reputation: 2158

It's not able to find your FFMpeg executable. Try adding the path to FFMPEG_BINARIES and FFPROBE_BINARIES in your .env file.

Edit 2022-06-13 Most times, just adding this two lines in your .env file will do.

FFMPEG_BINARIES=/usr/bin/ffmpeg
FFPROBE_BINARIES=/usr/bin/ffprobe

Upvotes: 6

Emeka Mbah
Emeka Mbah

Reputation: 17520

It's possible FFmpeg is not install on your OS. If you are using Ubuntu or Linux then run the command below to ensure FFmpeg is installed

ffmpeg -protocols

If you get

Command 'ffmpeg' not found, but can be installed with:

sudo apt install ffmpeg

Then install FFmpeg by running

sudo apt update
sudo apt install ffmpeg

Note on file path.

The default path for FFMpeg::open('') is storage\app

I was able to get this to work without setting binaries or making extract config settings

Also, you only need this composer require pbmedia/laravel-ffmpeg to get everything installed, it handles other depencies

Upvotes: 2

Related Questions