1

How to start wine in php shell_exec("wine ffmpeg.exe"); ?

(ubuntu version 14 server)

install

sudo apt-get install wine -y

php5 code:

$cmd = "/usr/bin/wine /var/www/html/ffmpeg.exe upload/image.jpg"
shell_exec($cmd);

ffmpeg.exe location: /var/www/html/

wine is not starting?

Linux version of FFmpeg?, how to run PHP shell_exec()?

Server domain is not on shared hosting

permissions on www-data could be problem?

command ffmpeg successfull in terminal!

there is a permission issue, just tested and command is correct.
either ffmpeg.exe or wine have incorrect permissions.

Command (ffmpeg.exe)

chmod 755 ffmpeg.exe
chown www-data ffmpeg.exe

Command (/usr/bin/wine)

chmod 755 wine
chown www-data wine


sudo service apache2 restart

still not working, could be more 'wine' files to apply permissions to. I'm not able to output any error, and command to ffmpeg is correct from terminal the problem must be permissions

Tamara Koliada
  • 1,200
  • 2
  • 14
  • 31
  • How on earth does this have five upvotes and two favourite stars? You "assume" it's not starting correctly? Why are you _assuming_ anything? Have you looked at the STDOUT, STDERR, or return value when you try to run the command? Yes, of course there is a Linux version of ffmpeg. A basic web search would have told you that. There's nothing special that needs to e done to run it via PHP. Please do basic research before asking here, and read [ask] for tips on asking effective questions. – ChrisGPT was on strike Jul 29 '17 at 01:20
  • (STDOUT) . $proc = popen($cmd, 'r'); echo $proc; = (OUTPUT) Resource id #20 – user235423423424 Jul 29 '17 at 01:28
  • shell_exec($cmd,$output);var_dump($output); (output) = NULL – user235423423424 Jul 29 '17 at 01:34

1 Answers1

2

First of all, download and install FFmpeg for your server: https://www.ffmpeg.org/download.html, yes, there are versions for Linux.

Then, it's better to use exec() and run ffmpeg on background, so you don't have to wait until the video is converted to go to another page.

$cmd = 'ffmpeg -- parameters here --';
// 2>&1 is used for execute on background
exec("$cmd 2>&1", $output);
// Do you need to debug?
// See ffmpeg results:
var_dump($output);
Triby
  • 1,739
  • 1
  • 16
  • 18
  • nothing wrong with the installation here, works when executed from terminal. must be file permissions since ffmpeg and shell_exec is running without errors – user235423423424 Jul 29 '17 at 05:34
  • Is PHP configured as CGI?, maybe you need to run php-cli in order to get this to work, check this: **[link](https://stackoverflow.com/questions/566248/cant-execute-php-script-using-php-exec)** – Triby Jul 29 '17 at 07:04
  • @user235423423424, you should avoid using Wine if you don't need it. It is _entirely_ unnecessary here. Simply use the native version of ffmpeg. This will almost certainly be faster, use less memory, and generate fewer errors. – ChrisGPT was on strike Jul 29 '17 at 12:26
  • Try to add the full path to your ffmpeg binary. For example `/usr/bin/ffmpeg`. You can locate the path using the command: `which ffmeg` in your terminal. – Yolo Jul 29 '17 at 23:15