Problem scenario: Use ffmpeg to transcode files.
Problem description: Use PHP to call the terminal ffmpeg command through the three methods of exec(), passthru(), and system() to achieve transcoding
The code is as follows:
<code>$cmd = '/usr/local/bin/ffmpeg -i test.mpg -c:v libx264 -b:v 1024k -b:a 128k -ar 16000 fina6555555431l.mp4'; echo shell_exec('whoami'); passthru($cmd,$res); var_dump('zhuangtai'.$res); </code>
Running this php file in the terminal can be transcoded normally
But accessing this file through the web cannot be transcoded. Why? ?
The full path of ffmpeg was not written before, and the status code of passthru() was that the command could not be found. Now, when accessing on the web, it returns 1, indicating that the execution was not successful.
Execute the php file directly in , the status is 0, and the execution is successful.
Is it possible that ffmpeg has a problem with user permissions?
The user printed in the web is www-data
The terminal is root
I have never done this before. What is the reason for this situation? . . .
. Urgent, urgent. . .
My brother is engaged in mobile development, but I’m not familiar with this. I’ve Googled a lot, but I haven’t found the reason or solution----
------! ! ! ! ! ! ! ! ! ! ! ! !