Last active
August 9, 2020 19:04
-
-
Save kekePower/d2dedcdc7409440610d893d855cefafa to your computer and use it in GitHub Desktop.
build.leia extension to download, compile and install ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extension to build and install FFmpeg | |
# See https://github.com/kekePower/build.leia | |
STANDALONE=true | |
FFMPEG_RELEASE=ffmpeg-3.4.2 | |
SOURCE=http://ffmpeg.org/releases/${FFMPEG_RELEASE}.tar.bz2 | |
FFMPEG=${KODIDIR}/depends | |
# Checking to see if either wget or curl is available. | |
if [[ -f $( which wget ) ]]; then | |
DOWNLOAD=wget | |
elif [[ -f $( which curl ) ]]; then | |
DOWNLOAD="curl -o ${FFMPEG_RELEASE}.tar.bz2" | |
else | |
echo "Could not find wget nor curl..." | |
clean_exit ${1} | |
fi | |
MSG="Preparing installation of ${FFMPEG_RELEASE}." | |
echo "${TIME}[$(date +%T)]${END} ${INFO}${MSG}${END}" | |
loggy ${MSG} | |
if [[ ! -d ${FFMPEG} ]]; then | |
mkdir -p ${FFMPEG} | |
fi | |
# We check if ffmpeg is installed and if it is, we use the configuration from that build | |
if [[ -f $( which ffmpeg ) ]]; then | |
FFMPEG_CONFIGURATION=$( ffmpeg 2>&1 | grep -i configuration | head -1 | cut -d: -f2 ) | |
fi | |
# We check if the source directory is present, if not, we download the source | |
if [[ ! -d ${FFMPEG}/${FFMPEG_RELEASE} ]]; then | |
MSG="Downloading ${FFMPEG_RELEASE} source..." | |
echo "${TIME}[$(date +%T)]${END} ${ARROW} ${Y}${MSG}${END}" | |
loggy ${MSG} | |
builtin cd ${FFMPEG} | |
${DOWNLOAD} ${SOURCE} >> ${LOGGYLOGFILE} 2>&1 | |
tar xfj ${FFMPEG_RELEASE}.tar.bz2 > /dev/null 2>&1 | |
else | |
MSG="Cleaning old configuration before new compilation." | |
echo "${TIME}[$(date +%T)]${END} ${ARROW} ${Y}${MSG}${END}" | |
loggy ${MSG} | |
builtin cd ${FFMPEG}/${FFMPEG_RELEASE} | |
make clean >> ${LOGGYLOGFILE} 2>&1 | |
fi | |
# We're now ready to configure and compile ffmpeg | |
if [[ -d ${FFMPEG}/${FFMPEG_RELEASE} ]]; then | |
MSG="Configuring ${FFMPEG_RELEASE}. Please wait..." | |
echo "${TIME}[$(date +%T)]${END} ${INFO}${MSG}${END}" | |
loggy ${MSG} | |
builtin cd ${FFMPEG}/${FFMPEG_RELEASE} | |
./configure $( echo ${FFMPEG_CONFIGURATION} ) >> ${LOGGYLOGFILE} 2>&1 | |
MSG="Compiling ${FFMPEG_RELEASE}. Please wait..." | |
echo "${TIME}[$(date +%T)]${END} ${INFO}${MSG}${END}" | |
loggy ${MSG} | |
make -s -j${NUMCPU} >> ${LOGGYLOGFILE} 2>&1 | |
if [[ -f ${FFMPEG}/${FFMPEG_RELEASE}/ffmpeg ]]; then | |
MSG="Installing ${FFMPEG_RELEASE}. Please wait..." | |
echo "${TIME}[$(date +%T)]${END} ${INFO}${MSG}${END}" | |
loggy ${MSG} | |
sudo make install >> ${LOGGYLOGFILE} 2>&1 | |
sudo make install-libs >> ${LOGGYLOGFILE} 2>&1 | |
sudo ldconfig -v >> ${LOGGYLOGFILE} 2>&1 | |
else | |
MSG="ffmpeg failed to compile..." | |
echo "${TIME}[$(date +%T)]${END} ${INFO}${MSG}${END}" | |
loggy ${MSG} | |
clean_exit ${1} | |
fi | |
fi | |
MSG="${FFMPEG_RELEASE} has been compiled and installed." | |
echo "${TIME}[$(date +%T)]${END} ${INFO}${MSG}${END}" | |
loggy ${MSG} | |
# Now remove the pid file and exit | |
clean_exit ${1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment