2

So I want to use FFMpeg library and found standalone PHP version, I used this before on Laravel and installed composer but now in this case, I am trying to install this library on a shared hosting, I just upload src folder and start with this:

<?php
$ffmpeg = FFMpeg\FFMpeg::create(array(
    'ffmpeg.binaries'  => 'FFMpeg/FFMpeg.php', 
    'ffprobe.binaries' => 'FFMpeg/FFProbe.php', 
    'timeout'          => 3600,
    'ffmpeg.threads'   => 12,  
));
$video = $ffmpeg->open('video.mpg');
?>

But got error:

PHP Fatal error: Uncaught Error: Class 'FFMpeg\FFMpeg' not found in...

So how can I use FFMpeg on a shared hosting and install it manually (without composer)

llogan
  • 121,796
  • 28
  • 232
  • 243
Jack The Baker
  • 1,781
  • 1
  • 20
  • 51
  • I hear you. When I asked about usage without Composer, for another library, I didn't receive much help. The problem is that composer does a lot in the background. It loads dependencies, sets up the class loader, and more. Once a library has gone the composer way the developers feel no need to support a manual install anymore. In an euphemistic way they will say that using composer is the 'recommended' or 'easiest' way to use their library. That said, any library can be used without composer, but it can be an effort to get it all working. See: https://github.com/PHP-FFMpeg/PHP-FFMpeg/issues/382 – KIKO Software Sep 22 '18 at 18:42
  • @KIKOSoftware The problem is I can't install composer on a shared hosting, so I can't use composer and have to do this manually, so I should give up on this, right? – Jack The Baker Sep 23 '18 at 07:19
  • I didn't say that. I've got some libraries working without composer, but as I said, it can be an effort. What I meant is that you should expect any help. Most people love composer, and they can't imagine you wouldn't want to, or can't, use it. – KIKO Software Sep 23 '18 at 07:44

1 Answers1

0

This is not a Composer free solution, but if you upload vendor (created by Composer) as well as your source and add:

require 'vendor/autoload.php';

to the head of the script (ensuring that the path is relative to the current script) it should be able to resolve the FFMpeg\FFMpeg class.

I'd suggest this is preferable as there are dependencies that PHP-FFMpeg has that you would also need to include, and Composer takes care of that.

msbit
  • 4,152
  • 2
  • 9
  • 22