# FFmpeg compilation for openSUSE Leap 15.x with OpenMeetings tutorials, not alone.
# Alvaro Bustos, thanks to Hunter.

# Install libraries
zypper install -y autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel libx264-devel

# Install yasm from repos
zypper install -y yasm

# Create a temporary directory for sources.
SOURCES=$(mkdir ~/ffmpeg_sources)
cd ~/ffmpeg_sources

# Download the necessary sources.
curl -#LO http://distfiles.macports.org/x264/x264-snapshot-20191217-2245-stable.tar.bz2
wget https://pkgs.rpmfusion.org/repo/pkgs/free/lame/lame-3.99.5.tar.gz/84835b313d4a8b68f5349816d33e07ce/lame-3.99.5.tar.gz
wget http://www.mirrorservice.org/sites/distfiles.macports.org/libopus/opus-1.2.1.tar.gz
wget https://download.videolan.org/contrib/vpx/libvpx-1.8.0.tar.gz
wget http://ffmpeg.org/releases/ffmpeg-5.1.tar.gz

# Unpack files
for file in `ls ~/ffmpeg_sources/*.tar.*`; do
tar -xvf $file
done

cd x264-*/
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static && make && make install && make distclean; cd ..

cd lame-*/
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm && make && make install && make distclean; cd ..

cd opus-*/
autoreconf -fiv && ./configure --prefix="$HOME/ffmpeg_build" --disable-shared && make && make install && make distclean; cd ..

cd libvpx-*/
./configure --prefix="$HOME/ffmpeg_build" --disable-examples && make && make install && make clean; cd ..

cp /root/ffmpeg_build/lib/pkgconfig/x264.pc /root/ffmpeg_build/lib64/pkgconfig

cd ffmpeg-*/
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib64/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build"  --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --pkg-config-flags="--static" --enable-gpl --enable-nonfree --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264 && make && make install && make distclean && hash -r; cd ..

cd ~/bin
cp ffmpeg ffprobe lame x264 /usr/local/bin

echo "...FFmpeg Compilation is Finished!"






