Apple - Installing ffmpeg from dmg and then running from a terminal, is there a better way?
You are supposed to copy the program from the disk image to your local folders. The usual place for these things is /usr/local/bin
So:
sudo mkdir -p /usr/local/bin
sudo cp /Volumes/FFmpeg\ 91200-g1616b1be5a/ffmpeg /usr/local/bin/
sudo chmod +x /usr/local/bin/ffmpeg
and all should be good to go. Disabling SIP not required.
No need for homebrew or any other package handler to install a precompiled binary. You do need to read up on basic UNIX though.
The problem is bash
is looking for ffmpeg
in directories list in the $PATH
. Some of these directories are protected by SIP and therefore you would need to disable SIP to put the file in these directories. Alternatively, you can install it using Homebrew.
First install HomeBrew with this command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then install ffmpeg
with this command:
brew install ffmpeg
Homebrew will install ffmpeg in a path not protected by SIP, but within the $PATH
, more specifically it will install it under the /usr/local/bin
directory.
This can be done manually with manual commands (basically manually doing what homebrew does. For this approach check out @davids answer. But I would suggest homebrew for multiple reasons. Its much easier to use and quicker to install a large amount of tools. You can also update much faster. Homebrew also makes installing dependencies easier.
Edit: I previously had a part of this answer with inaccurate information I have since changed it. I believe it is currently accurate. I have included the part about SIP because I think it is important to understand what restrictions there are regarding placement of commands and why there isn't just a single path for all commands.
The terminal shell of macOS, as in Windows or Linux, is looking in the $PATH
environment variable to locate binaries.
You can check your $PATH
variable doing :
echo $PATH
Which outputs in standard recent macOS :
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
You either have to put a copy of the binary in one of those directory (preferably /usr/local/bin as it is not SIP-protected) or add another directory in your $PATH
environment variable.
The best practice is generally to store your application elsewhere (e.g. /lib
) and to only put a symlink in the bin directory pointing to the binary itself. This is less true for self-contained binary but mandatory if you want to run an executable that resides inside an .app (e.g. /Applications/VLC.app/Contents/MacOS/VLC
)