[FFmpeg-user] Calling FFmpeg from PHP: How to set logfile? (report)

Peter B. pb at das-werkstatt.com
Sat Jul 27 23:19:14 EEST 2019


Thanks for your replies! :)


On 27/07/2019 21:18, Reindl Harald wrote:
>> https://www.php.net/manual/en/function.putenv.php 
> but how does it matter anyways?

Sure I found putenv before, but as I said: It felt a bit unnecessarily
complicated ("overkill"), so I thought I'd better ask.


> you are supposed to use things like
> https://www.php.net/manual/en/function.exec.php when you execute
> binaries like ffmpeg

I know. That's what I'm doing.
btw: The PHP article in the wiki only mentions "shell_exec()" - and no
means of evaluating any exitcode to see if the FFmpeg call was
successful or not. So I found "exec()" to actually be the better option
(for me?)

So I'm now doing the following and it seems to work quite well:

1) Add "2>$logfile" at the end of the command to redirect stderr to file.
2) Use "exec($command, $output, $exitcode)" - and then check if
($exitcode != 0).

Seems to work quite well!



> [...] execute wahter application from PHP is
> fine as long as you restrict it to an instacne for special purpose while
> passthru and freinds should be diabled on random webservers
>
> not because PHP is insecure but because the power of shell commands and
> power always brings responsibility

I'm aware of PHP's shortcomings, but this is not a web application and
it only runs locally.


Thanks again for your time and for somewhat confirming my approach!

Nice greetings,
Peter B.



More information about the ffmpeg-user mailing list