2

I am using FFmpeg with PHP on CentOS server. the php code is

$thumbnail = $this->generateRandomString(25);
$ffmpeg = "/usr/bin/man"; // or /usr/share/ffmpeg {not working}
$videoFile = $_FILES['file']['tmp_name'];
$imageFile = "uploads/images/video_thumbnail/$thumbnail.jpg";
$size = '340x250';
$getFrom = 10;
$cmd = "$ffmpeg -i $videoFile -an -ss $getFrom -s $size $imageFile";
shell_exec($cmd);

When running command $whereis FFmpeg

output is : ffmpeg: /usr/bin/ffmpeg /usr/share/ffmpeg /usr/share/man/man1/ffmpeg.1.gz

So what's the correct path.

Ashraf Hefny
  • 508
  • 1
  • 6
  • 20
  • `/usr/bin/ffmpeg` is the correct path to the ffmpeg binary. – cOle2 Dec 30 '14 at 17:32
  • I tried it not work @cOle2 – Ashraf Hefny Dec 30 '14 at 17:37
  • Based on your `whereis` command that should be the correct path. You can try and verify it's location by running `/usr/bin/ffmpeg -h` from the command line. If your code doesn't work with the correct path that's an entirely different issue. – cOle2 Dec 30 '14 at 17:43
  • @cOle2 /usr/bin/ffmpeg -h displaying help successfully, so the error in the php code ? where ? the video has beem uploaded but the thumbnail was not taken – Ashraf Hefny Dec 30 '14 at 17:52
  • echo the `$cmd` and run it manually on the commandline. FFMpeg should output an error and you can go from there. – cOle2 Dec 30 '14 at 17:54
  • I use FFmpeg from PHP in a few of my projects, I don't usually need to enter a path at all, just `ffmpeg -i...`. like @cOle2 has suggested I would try to run the command directly in the terminal first and make sure that it actually works. I recently had an issue where I couldn't run a command from PHP but it worked fine on the command line, I eventually solved the issue by chowning the executable I was trying to run so that it was owned by the apache user and also added the folder for the executable to my path. – Scriptable Dec 31 '14 at 12:27
  • Possible duplicate of [GLIBCXX\_3.4.9 not found when running ffmpeg from php in lampp server](https://stackoverflow.com/questions/31353604/glibcxx-3-4-9-not-found-when-running-ffmpeg-from-php-in-lampp-server) – Rohan Khude Aug 20 '18 at 19:16

2 Answers2

4

Use simpe code:

$ffmpegPath = exec('which ffmpeg');
$ffprobe = exec('which ffprobe');
Sergey Kozlov
  • 452
  • 5
  • 17
0

This is an old question, but I thought to still add: You can even use the command "type ffmpeg" to get the ffmpeg location.

Shai Alon
  • 969
  • 13
  • 21