-
-
Notifications
You must be signed in to change notification settings - Fork 170
FFmpeg
To use audio with the homebridge-ring plugin, you must have ffmpeg
installed with the libfdk_aac
library. Find your operating system below and run the suggested commands.
Once you have ffmpeg
with libfdk_aac
installed on your homebridge server, you should immediately be able to receive audio in your camera streams. There are a few known issues at this point:
- Audio takes a few seconds to start after video stream appears - this lag time is due to
ffmpeg
taking some time to start up. I might be able to reduce this delay in the future, but no promises. - No two-way audio yet
These instructions are borrowed from https://github.com/KhaosT/homebridge-camera-ffmpeg/wiki/Raspberry-PI
# install build tools
sudo apt-get install git pkg-config autoconf automake libtool libx264-dev
# download and build fdk-aac
git clone https://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
./autogen.sh
./configure --prefix=/usr/local --enable-shared --enable-static
make -j4
sudo make install
sudo ldconfig
cd ..
# download and build ffmpeg
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure --prefix=/usr/local --arch=armel --target-os=linux --enable-omx-rpi --enable-nonfree --enable-gpl --enable-libfdk-aac --enable-mmal --enable-libx264 --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-demuxer=rtsp
make -j4
sudo make install
Create an sh script
sudo nano install_ffmpeg_libfdkaac.sh
Copy and Paste this into the script
apt-get update
apt-get -y install autoconf automake build-essential git-core libass-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev libmp3lame-dev nasm gcc yasm && true
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make -j8
make install
make distclean
cd ~/ffmpeg_sources
wget https://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make -j8
make install
make distclean
cd ~/ffmpeg_sources
wget https://ffmpeg.org/releases/ffmpeg-4.2.1.tar.gz
tar xzvf ffmpeg-4.2.1.tar.gz
cd ffmpeg-4.2.1
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
export PKG_CONFIG_PATH
./configure --prefix="$HOME/ffmpeg_build" \
--extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac \
--enable-libmp3lame --enable-nonfree
make -j8
make install
cp ffmpeg /usr/bin/
make distclean
hash -r
ffmpeg 2>&1 | head -n1
Make script executable and run
sudo chmod +x install_ffmpeg_libfdkaac.sh
sudo ./install_ffmpeg_libfdkaac.sh
First, access the docker image:
# access docker container shell (I recommend this vs the web UI, as the web UI may time out)
cd /home/pi/homebridge
docker-compose exec homebridge sh
Then, install/build ffmpeg. These commands may work, but have not been tested. Pulled from https://github.com/oznu/docker-homebridge/issues/82#issuecomment-374497842
apk del ffmpeg ffmpeg-libs
apk --allow-untrusted add --no-cache --repository http://alpine.dl.oz.nu/ffmpeg ffmpeg ffmpeg-libs
If those commands fail, try these commands courtesy of @ifeign in #114
# install build tools
apk add git pkgconfig autoconf automake libtool x264-dev
# download and build fdk-aac
git clone https://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
./autogen.sh
./configure --prefix=/usr/local --enable-shared --enable-static
make -j4
sudo make install
sudo ldconfig
cd ..
# download and build ffmpeg
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure --prefix=/usr/local --arch=armel --target-os=linux --enable-nonfree --enable-gpl --enable-libfdk-aac --enable-libx264 --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-demuxer=rtsp
make -j4
sudo make install
First install HomeBrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then install homebrew-ffmpeg
brew tap homebrew-ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-fdk-aac
If you are running homebridge on a different platform, you will need to research how to build ffmpeg. The most important part is that you include --enable-libfdk-aac
when building ffmpeg
to enable the libfdk_aac
codec.