On Linux, what is the reason for the failure of exec () execution in the php file?

I use the command
ffmpeg-I / home/video/a.mp4-r 1-s 950x520-f image2 / home/video/a.jpg
can be executed on the terminal,
but in the PHP file, I run
exec ("ffmpeg-I / home/video/a.mp4-r 1-s 950x520-f image2 / home/video/a.jpg") through a browser but fail.
online Baidu says it"s a permission problem, so test,

echo shell_exec ("ls") can execute
echo shell_exec (" whoami") to display nginx

so vim / etc/sudoers adds

Allow root to run any commands anywhere
root ALL= (ALL) ALL
nginx ALL= (ALL) ALL

after saving, reboot restarts but it doesn"t work.
A lot of people have this problem on the Internet, but I don"t see a useful solution. I hope you can give me an answer if you still know.

Sep.28,2021

1,
should still be a permission problem.
it is critical that the user who executes exec using php in the browser can execute the command ffmpeg.
seeing that you mentioned nginx, I guess it may be nginx + php-fpm, so it depends on whether the executive user of php-fpm has permission, not nginx.

< hr >

2,
you can view running error messages.
for example, change to

exec("ffmpeg -i /home/video/a.mp4 -r 1 -s 950x520 -f image2 /home/video/a.jpg 2>&1 ",$error);
< hr >

3,
further on, one possible reason is that sh: ffmpeg: command not found , then it is not a question of permissions. It is that nginx users cannot find this command, that is, nginx users cannot find this command in the $PATH environment variable. At this time, you can write all the command paths
such as / usr/bin/ffmpeg * . Of course, you have to find out for yourself what the specific all paths are.

just look for more reasons. I hope it will be helpful to you. Before, it was unclear

2. Use a browser to access the PHP file and view the page output
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea751c-1e45.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea751c-1e45.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?