I have installed ffmpeg by following this tutorial on trac.ffmpeg.org
Now, ffmpeg works if I cd to bin and execute it with ./ffmpeg
I wonder if I could execute ffmpeg just by typing ffmpeg in a terminal from anywhere.
2 Answers
You don't need to edit your PATH or ~/.bashrc
The guide "installs"
ffmpeginside~/binso it does not potentially interfere with conflicting repository packages.There is no need to edit your
PATHor~/.bashrcas shown in the accepted answer.~/binis already in thePATHby default (take a look at~/.profile), but~/binis not included when you login if it does not exist (and it did not exist before you compiled), but you can easily "refresh" it as shown below.
All you need to do is this:
hash -r
. ~/.profileAlternatively you can simply log out then log in.
Now you can run ffmpeg from any directory and it will automatically execute the ffmpeg binary in ~/bin (for the particular user who compiled ffmpeg). All of this is explained in the guide you linked to.
Getting it to work for all users
The above instructions are for the single user who compiled ffmpeg. If you have multiple users you can just move or copy the compiled ffmpeg binary into /usr/local/bin.
You can simply add ffmpeg directory to your $PATH. Assuming you're using bash open ~/.bashrc file and add at the bottom:
export PATH=$PATH:<path where you installed ffmpeg>and reload bash ( close and open terminal again or type 'bash' ).
edit: PATH represents list of directories that your shell is using to find binary files. So you need to add directory, not the file, path to that variable. Assuming that you executed everything exactly the way that manual said you need to add to you .bashrc that command:
export PATH=$PATH:$HOME/bin 4