Home > Backend Development > PHP Tutorial > The php ffmpeg passthru() function can be transcoded when executing a php file in the terminal, but cannot be transcoded when accessing the php file via the web. what reason? ?

The php ffmpeg passthru() function can be transcoded when executing a php file in the terminal, but cannot be transcoded when accessing the php file via the web. what reason? ?

WBOY
Release: 2016-08-29 08:35:48
Original
1374 people have browsed it

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>
Copy after login

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----

------! ! ! ! ! ! ! ! ! ! ! ! !

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template