Skip to content

Instantly share code, notes, and snippets.

@lebensterben
Last active January 29, 2020 08:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lebensterben/6015c68119266009d2c1543617ffdb76 to your computer and use it in GitHub Desktop.
Save lebensterben/6015c68119266009d2c1543617ffdb76 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
## References:
## https://community.clearlinux.org/t/how-to-h264-etc-support-for-firefox-including-ffmpeg-install
## Install dependencies
echo -e "\e[33m\xe2\x8f\xb3 Install the following dependencies: 'c-basic', 'devpkg-libva', and 'git' ...\e[m"
sudo swupd bundle-add c-basic devpkg-libva git
## Clone the ffmpeg git repository if it doesn't exist; or update it if it exists
echo -e "\e[33m\xe2\x8f\xb3 Get latest FFmpeg source repository ...\e[m"
if [ -d "FFmpeg" ];then
# shellcheck disable=SC2164
cd FFmpeg
git pull
else
git clone https://github.com/FFmpeg/FFmpeg
# shellcheck disable=SC2164
cd FFmpeg
fi
## Get the latest non-dev release
echo -e "\e[33m\xe2\x8f\xb3 Checkout the latest non-dev release ...\e[m"
git checkout tags/"$(git tag -l | grep 'n' | grep -v 'dev' | tail -1)"
## Build FFmpeg, which would be installed under /opt/ffmpeg
echo -e "\e[33m\xe2\x8f\xb3 Building ...\e[m"
echo -e "\e[32m If the installation is successful, it would be available under \e[33m/opt/ffmpeg\e[32m.\e[m"
read -rp "Press any key to continue ... " -n1 -s
echo
if ! ./configure --prefix=/opt/ffmpeg --enable-shared && make && sudo make install; then
echo -e "\e[31m Installation failed! Aborting...\e[m"
exit 1
fi
## Configure the dynamic linker configuration to include /opt/ffmpeg/lib
echo -e "\e[33m\xe2\x8f\xb3 Configuring dynamic linker configuration ...\e[m"
if [ ! -f /etc/ld.so.conf ] || [ "$(grep 'include /etc/ld\.so\.conf\.d/\*\.conf' /etc/ld.so.conf )" = '' ]; then
printf "/etc/ld.so.conf\ninclude /etc/ld.so.conf.d/*.conf" | sudo tee -a /etc/ld.so.conf
fi
if [ ! -d /etc/ld.so.conf.d ]; then
sudo mkdir /etc/ld.so.conf.d
fi
echo "/opt/ffmpeg/lib" | sudo tee /etc/ld.so.conf.d/ffmpeg.conf
echo -e "\e[32m Updating dynamic linker run-time bindings and library cache ...\e[m"
sudo ldconfig
## Add ffmpeg to library path of Firefox
echo -e "\e[33m\xe2\x8f\xb3 Add FFmpeg to libarry path of Firefox ...\e[m"
if [ ! -f "${HOME}/.config/firefox.conf" ] || [ "$(grep 'export LD_LIBRARY_PATH' "${HOME}/.config/firefox.conf")" = '' ]; then
echo "export LD_LIBRARY_PATH=/opt/ffmpeg/lib" >> "${HOME}/.config/firefox.conf"
else
grep -q 'export LD_LIBRARY_PATH=.*/opt/ffmpeg/lib' "${HOME}/.config/firefox.conf" \
|| sed -i 's#export LD_LIBRARY_PATH=#&/opt/ffmpeg/lib;#' "${HOME}/.config/firefox.conf"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment