FFmpeg is a free and open-source project consisting of a vast software suite of libraries and programs for handling video, audio, and other multimedia files and streams. (Wikipeida)
Before install
first of all you need install brew, copy and paste the following command to your terminal
/usr/bin/ruby -e "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/master/install>)"
Install FFmpeg
you can’t directly run brew install ffmpeg yet, base on official documentation.
Since v2.0, Homebrew does not offer options for its core formulae anymore. Users who want to build ffmpeg with additional libraries (including non-free ones) need to use so-called taps from third party repositories. These repositories are not maintained by Homebrew.
for example, you need both x264 and x256(HEVC) encoder support. (what is the difference between H.264 & H.265, what is NVENC from Nvidia? I will write a blog special for it.)
you have to tap third party brew repository, step by step, you will get there.
add third party tap to brew
brew tap homebrew-ffmpeg/ffmpegcheck options
brew options homebrew-ffmpeg/ffmpeg/ffmpeginstall every options (if never know which codec you gonna to using)
brew install homebrew-ffmpeg/ffmpeg/ffmpeg $(brew options homebrew-ffmpeg/ffmpeg/ffmpeg | grep -vE '\\s' | grep -- '--with-' | tr '\\n' ' ')
Test FFmpeg
please download sample H.264 , and navigate to that file located folder, and run
ffmpeg -i test.mp4 -c:v libx265 -c:a copy x265.mp4
you’ll get x265.mp4 at the same folder.
let me explain a bit for this command,
- i : input file
- c:v : covert video, libx256 is the video codec we’re using here, default present option for libx256 is medium
- c:a : covert audio, copy means use copy the audio in it’s original codec, if we put nothing for audio, by default it will convert original audio to acc via acc codec (what’s the difference between acc and mp3, I will talk about this in another blog post)
if you’re interested on more FFmpeg common scripts and explanation, please waiting for me next blog post.
Cheers and Stay hungry.