I am planning to create a new app for personal use on my Mac that uses FFMPEG library, to store a feed from a RTSP IP camera.
Following this official installation procedure from FFMPEG I have manage to successfully achieve the following 2 steps:
To get ffmpeg for OS X, you first have to install Homebrew. If you don't want to use Homebrew, see the section below.
Then:
- brew install automake fdk-aac git lame libass libtool libvorbis
libvpx \ opus sdl shtool texi2html theora wget x264 xvid yasm
Question: My question here because I am confused, is how to import a library into Xcode so I can use it in the application I am about to build for my Mac. I can see plenty of GitHub projects related to FFMPEG with IOS/Android, but none for OSX.
All the FFMPEG commands under terminal are working fine, such as converting a video etc.
Download ffmpeg and ffprobe. Go to https://ffmpeg.org/download.html and click the Apple logo in the "Get packages & executable files" section. Click "Static builds for macOS 64-bit". You'll see two options for downloading ffmpeg. Choose the one with the shorter filename; this will look like ffmpeg-<versionNumber>.
In Terminal, navigate to the folder containing the ffmpeg file using the "cd" (change directory) command. Type "cd" followed by the file path to your Downloads folder. For example, the path on my system is "/Users/aaron/Downloads".
Mac/Linux. Open a terminal window by pressing command and space on your keyboard to open Spotlight, typing Terminal, and pressing enter. Check if you have ffmpeg installed and what version you have installed. In the terminal, type ffmpeg -version and press enter.
If you look in /usr/local/Cellar/ffmpeg
you will find the actual ffmpeg
package and everything in homebrew
is just symbolic links to that. For example:
/usr/local/bin/ffmpeg -> ../Cellar/ffmpeg/3.0.2/bin/ffmpeg
Now, if you stay in that directory and do this, you will find all the pkgconfig
configuration settings for the constituent parts of ffmpeg
:
find . -name \*.pc
./lib/pkgconfig/libavcodec.pc
./lib/pkgconfig/libavdevice.pc
./lib/pkgconfig/libavfilter.pc
./lib/pkgconfig/libavformat.pc
./lib/pkgconfig/libavresample.pc
./lib/pkgconfig/libavutil.pc
./lib/pkgconfig/libpostproc.pc
./lib/pkgconfig/libswresample.pc
./lib/pkgconfig/libswscale.pc
That means you can now find the include
path and library
paths that you need to put in the Xcode settings. So, for example, if you want the includes
for libavutil
, you can do:
pkg-config --cflags libavutil
and it will tell you:
-I/usr/local/Cellar/ffmpeg/3.0.2/include
If you want the library
settings for libavfilter
, you can do:
pkg-config --libs libavfilter
and it will tell you
-L/usr/local/Cellar/ffmpeg/3.0.2/lib -lavfilter
So that is how you get the settings for the compiler/linker. Then you need to put them into Xcode, and I have described that here - look at the bit with the yellow, red and blue boxes.
Hope that helps. Oh, you need to do:
brew install pkg-config
first to get the pkgconfig
binary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With