Compile FFmpeg with RTMPS for Facebook

Compile FFmpeg with RTMPS for Facebook

Facebook announced that "Live Video streams on Pages and Workplace can use the non-encrypted standard RTMP protocol until November 1st, 2019, after which RTMP will no longer be supported".

On May 1st, 2019, the Real-time Messaging Protocol (RTMP) has been   deprecated from the Live API, GoLive Dialog, and Publisher Pages. RTMPS (RTMP over a TLS/SSL connection) will continue to be supported.

facebook deprecated RTMP, Pages & workplace on Nov, 2019

Live streaming to facebook need RTMPS, but unfortunately most FFmpeg not enable openssl which need.

Install the dependencies

apt-get -y install build-essential autoconf automake cmake libtool git checkinstall nasm yasm libass-dev libfreetype6-dev libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev libchromaprint-dev frei0r-plugins-dev ladspa-sdk libcaca-dev libcdio-paranoia-dev libcodec2-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgme-dev libgsm1-dev libjack-dev libmodplug-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenjp2-7-dev libopenmpt-dev libopus-dev libpulse-dev librsvg2-dev librubberband-dev librtmp-dev libshine-dev libsmbclient-dev libsnappy-dev libsoxr-dev libspeex-dev libssh-dev libtesseract-dev libtheora-dev libtwolame-dev libv4l-dev libvo-amrwbenc-dev libvpx-dev libwavpack-dev libwebp-dev libx264-dev libx265-dev libxvidcore-dev libxml2-dev libzmq3-dev libzvbi-dev liblilv-dev libmysofa-dev libopenal-dev opencl-dev gnutls-dev libfdk-aac-dev

Prepare source code

#clone source code (parameter list)
#git clone ffmpeg
#git checkout 4154f89

tar -xvf n4.1.3.tar.gz

cd FFmpeg-n4.1.3


To use RTMPS, module "openssl" is require.

sample 1

./configure --disable-shared --enable-static --enable-pthreads --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-filters --enable-openssl --enable-runtime-cpudetect --extra-version=patrickz

sample 2

./configure --disable-shared --enable-static --enable-pthreads --enable-nonfree --enable-version3 --enable-hardcoded-tables --enable-avresample --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex  --disable-libjack --disable-indev=jack --enable-libsoxr --enable-openssl --enable-runtime-cpudetect --extra-version=patrickz


make install

Please note that "make install" may replace (ffmpeg) old one or affect your current version. You can use absolute path (i.e. /root/FFmpeg-n4.1.3/ffmpeg) until you sure that it work as expected.


./ffmpeg -f lavfi -re -i "life=s=300x200:mold=10:r=25:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16" -f lavfi -re -i sine=frequency=1000:sample_rate=44100 -pix_fmt yuv420p -c:v libx264 -b:v 1000k -g 30 -keyint_min 120 -profile:v baseline -preset veryfast -c:a aac -b:a 96k  -f flv "rtmps://{YOUR STREAM KEY}"

I use FFmpeg Filters to simulate as video source. Don't forget change {YOUR STREAM KEY} to your stream key then enter the command.

FFmpeg stream to facebook

If you see screen as above, seem it work and you could see incoming video stream on Facebook Live control panel.

facebook live control panel

Now you can live streaming to facebook with RTMPS. Hope you enjoy. Have a nice day!