6

I've written a php program which creates a video from sequence of images using ffmpeg.

<?php
    $res = shell_exec("ffmpeg -framerate 50 -i image/image%d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4 2>&1");
    echo "$res";

When I run it,

it says GLIBCXX_3.4.15 , GLIBCXX_3.4.9 , GLIBCXX_3.4.11 not found.

ffmpeg: /opt/lampp/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not

found (required by /usr/lib/i386-linux-gnu/libjack.so.0) ffmpeg:

/opt/lampp/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found

(required by /usr/lib/i386-linux-gnu/libzmq.so.3) ffmpeg:

/opt/lampp/lib/libstdc++.so.6: version `GLIBCXX_3.4.11' not found

(required by /usr/lib/i386-linux-gnu/libopencv_core.so.2.4) ffmpeg:

/opt/lampp/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found

(required by /usr/lib/i386-linux-gnu/libopencv_core.so.2.4)

But from the terminal, ffmpeg -framerate 50 -i image/image%d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4 command works fine. Why php can't find the libraries while from the terminal it works fine? and what should I do to fix the problem in php? Thanks in advance.

Community
  • 1
  • 1
Rafaf Tahsin
  • 7,652
  • 4
  • 28
  • 45

2 Answers2

18

I also got similar problem while executing the ffmpeg command from PHP script. I found the solution by executing the following command from the terminal. I am pasting that command here so somebody get help from this.

sudo mv /opt/lampp/lib/libstdc++.so.6 /opt/lampp/lib/libstdc++.so.6.orig

Now just run your php script, hope that will work.

Shwetha
  • 903
  • 8
  • 15
  • 1
    On the time I posted this question, I was not using linux, I was using xampp inside windows. So I couldn't try your suggestion. But I'm marking this as correct answer as this is the most helpful answer regarding this issue so far. – Rafaf Tahsin Sep 05 '16 at 07:58
  • I have tried this but now the problem was my php script is just loading. – Nikkolai Fernandez Nov 08 '19 at 05:07
0

If u have tried all the above methods(change name to .orig/_old, copy newer version to the lib folder, change LD_LIBRARY_PATH in xampp),

but still failed to solve this problem. Try this trick which worked for me finally:

1.add below line in your PHP file.

var_dump(shell_exec("whoami"));

you can find the username in your browser after clicking the url related to your PHP file

2.in your terminal

sudo vim /ect/sudoers

#in vim editor, add this line in your sudoers file
"username ALL=(ALL) NOPASSWD:ALL"
#change username to that found in step one 

3.change the exec cmd in your PHP file to

exec("sudo python3 urfilename.py")

The main reason for your problem maybe the root permission, so by changing your sudoers file, the error might be tackled.

Wang Wei
  • 39
  • 3