0

I have dedicated server. I have installed FFmpeg on my root. All commands related to FFmpeg works if I logged in as root but no command is working if I logged in as user. I have tried adding one user to sudoers also. Also I want to use FFmpeg commands in PHP shell_exec() or exec(). Can someone tell me the solution. Thanks in advance.

user command:

$ ffmpeg

output:

-bash: ffmpeg: command not found

root command:

$ ffmpeg

output

ffmpeg version N-93394-g14eea7c Copyright (c) 2000-2019 the FFmpeg 
developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-23)
configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static -- 
extra-cflags=-I/root/ffmpeg_build/include -
-extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs=-lpthread --extra- 
libs=-lm --bindir=/root/bin --enable-gpl --enab
le-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus -- 
enable-libvpx --enable-libx264 --enable-libx
265 --enable-nonfree
libavutil      56. 26.100 / 56. 26.100
libavcodec     58. 47.103 / 58. 47.103
libavformat    58. 26.101 / 58. 26.101
libavdevice    58.  6.101 / 58.  6.101
libavfilter     7. 48.100 /  7. 48.100
libswscale      5.  4.100 /  5.  4.100
libswresample   3.  4.100 /  3.  4.100
libpostproc    55.  4.100 / 55.  4.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] 
outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'
  • In what way do the commands not work? Please put the exact command line you use and paste the entire output / error response message. – L. Scott Johnson Mar 20 '19 at 11:53
  • When I am trying to fire FFmpeg by logging in as a non root user I am getting error -bash: ffmpeg: command not found – Prashant Hanamghar Mar 20 '19 at 11:56
  • That means it's not in the user's path. Check the PATH setting and make sure it includes /usr/local/bin or wherever you installed ffmpeg. (Also: edit your question to include this information) – L. Scott Johnson Mar 20 '19 at 11:58
  • I found PATH using command $ whereis ffmpeg & I got the PATH /usr/include/ffmpeg. After using this path I am getting same error. Thanks for the replay. – Prashant Hanamghar Mar 20 '19 at 12:04
  • How are you "using this path"? "include" is not usually a place to keep binaries. Show the output of `which ffmpeg` when run as root. Then use that complete line (full path plus ffmpeg) as the other user. – L. Scott Johnson Mar 20 '19 at 12:07

1 Answers1

1

Ensure that the user's PATH includes the directory in which the ffmpeg binaries are located (usually /usr/local/bin or /opt/local/bin ).

If you can't find it, you can ask the system which one it uses when you're logged in as root with the command:

which ffmpeg

In your case, per the info you've added to the question, it looks like the binaries are in /root/bin

Which may be a problem in itself, if /root/bin is not world readable and the contents world executable.

L. Scott Johnson
  • 4,213
  • 2
  • 17
  • 28
  • Thanks for the reply. I used command which ffmpeg and got new path /root/bin/ffmpeg. Using this PATH it is giving error - -bash: /root/bin/ffmpeg: Permission denied – Prashant Hanamghar Mar 20 '19 at 12:10
  • Right. The best solution would be to re-build the binaries in a suitable place (i.e., redo your configuration to put the binaries in /usr/local/bin ). But at the very least, you need to ensure the directory where they are is world readable and the binaries are world readable and world executable. – L. Scott Johnson Mar 20 '19 at 12:12
  • Thanks L. Scott Johnson. With your help I solved my problem using - https://superuser.com/questions/1080027/install-ffmpeg-in-redhat-linux-via-rpm-for-a-non-root-user/1080084#1080084 – Prashant Hanamghar Mar 20 '19 at 12:46
  • @PrashantHanamghar Assuming you have root access (I'm assuming you're the user who actually compiled ffmpeg), and alternative solution would have been to simply copy or move the ffmpeg file from `/root/bin` to `/usr/local/bin` and give it the proper permissions to execute by other users. – llogan Mar 20 '19 at 17:13