You got lost with what you're doing. Compare your script with this one.
Copy#!/bin/bash
# Still to come, see if the script runs with root privileges else exit
# Download FFMPEG static daily build and it's md5
# or exit if not
cd ~ || exit 2
# 1. get the file
wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-64bit-static.tar.xz
# 2. Check the md5 is correct
if ! diff <(md5sum ffmpeg-git-64bit-static.tar.xz) \
<(curl -L https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-64bit-static.tar.xz.md5)
then
printf "%s\n" "md5sum doesn't match..." >&2
exit 1
fi
# 3. untar
tar -xf ffmpeg-git-64bit-static.tar.xz
# 4. and so on..
cp ffmpeg-*-static/ff* /usr/bin/
cp ffmpeg-*-static/ff* /usr/local/bin/
cp ffmpeg-*-static/qt-faststart /usr/bin/
cp ffmpeg-*-static/qt-faststart /usr/local/bin/
# Consider change second location to use ln -s
# Remove downloads and do some clean up
rm -fr ffmpeg-*
#EOF
A few fixes to your updated version. I removed your comments to make my own visible.
Copy#!/bin/bash
download_dir=~
dest_dir=/usr/bin/
version=ffmpeg-git-64bit-static.tar.xz
source_url=https://johnvansickle.com/ffmpeg/builds/${version}
md5_url=https://johnvansickle.com/ffmpeg/builds/${version}.md5
# You need braces to build blocks.
# As it was, your script terminated at the exit. Regardless. End of story.
cd ${download_dir} || {
printf "%s\n" "You can't enter this folder." "Please change download_dir in this script..." >&2
exit 1
}
if ! diff <(md5sum ${version}) <(curl -s ${md5_url})
then
# Sum doesn't match is not really an error... I comment out the redirection.
printf "%s\n" "md5sum doesn't match..." "Downloading new version" # >&2
rm -f ${version} # >&2 -- Why would you redirect any output to stderr?
curl ${source_url} -o ${download_dir}/${version} # >&2 -- Same as above.
else
# You've done this already.
# diff <(md5sum ${version}) <(curl -s ${md5_url})
printf "%s\n" "Nothing new to download" # >&2 -- Why is this an error?
exit # 3 -- I don't think this is any error. You checked and it's fine.
# It might stay if you really MEAN it.
fi
# I'm not checking further.
tar -xf ffmpeg-git-*-static.tar.xz
mv ${download_dir}/ffmpeg-*-static/ff* "${dest_dir}"
mv ${download_dir}/ffmpeg-*-static/qt-faststart "${dest_dir}"
ln -sfn ${dest_dir}/qt-faststart /usr/local/bin/qt-faststart
ln -sfn ${dest_dir}/ffmpeg /usr/local/bin/ffmpeg
ln -sfn ${dest_dir}/ffmpeg-10bit /usr/local/bin/ffmpeg-10bit
ln -sfn ${dest_dir}/ffprobe /usr/local/bin/ffprobe
ln -sfn ${dest_dir}/ffserver /usr/local/bin/ffserver
rm -fr ffmpeg-git-*-static
Answers to your comment questions.
When is something to be determined as blocks?
Here you can get a wider picture of blocks. In Bash they're called lists. Run this:
Copyman bash | grep -A 30 'Compound Commands'and see what Bash's man has to say about them for a good start. This guide should be more approachable.
How to make it output the current running command to the console ex. the
tar -xfetc.?The only ready solution I know for this is to run Bash in the debugging mode, if that's what you want. You can turn it on anywhere in the script with
Copyset -xThen you turn it off with:
Copyset +xYou can do the same in the command line.
You can also set the whole script to run in this mode in the shebang.
Copy#!/bin/bash -xOr you can tell the interpreter from the command line to run in this mode,
Copy
bash -x ~/bin/your_script.bash
linux - bash script to install / update ffmpeg static builds - Stack Overflow
linux - How to compile FFmpeg as static (single file) - Stack Overflow
Can anyone tell me how you compile ffmpeg from a GitHub version, preferably into a static build?
What is ffmpeg static build?
Videos
» npm install ffmpeg-static
What is ffmpeg static build? What are the difference between ffmpeg Linux official packages, ffmpeg static build & ffmpeg compilation?
In my CentOS 5.11 and FFmpeg 3.0, I have to use options
--pkg-config-flags="--static"
--extra-cflags="-I$HOME/ffmpeg/include -static"
--extra-ldflags="-L$HOME/ffmpeg/lib -static"
--enable-static tell a complier to create the "static libraries" (libav*.a). We can be combine FFmpeg API in the other standalone (static) application.
--disable-shared tell a complier not to create the "dynamically linked shared object libraries" (libav*.so). These type of libraries can be load and use FFmpeg API by the other application.
These 2 options doesn't complie FFmpeg as standalone static executable.
Thanks for stib's suggestion. I leave my answer here.
FFmepg build process take higher priority to use dynamic library even if static libraries are ready. Therefore, I first removed some external libraries support from build configuration and make sure all external libraries are only static (remove *.dylib from prefix /usr/local/lib). Then rebuild it with the following command:
./configure --pkg-config-flags="--static" --libdir=/usr/local/lib --extra-version=ntd_20150128 --disable-shared --enable-static --enable-gpl --enable-pthreads --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-filters --enable-runtime-cpudetect
Remember to define --pkg-config-flags="--static", asking build process to use static library. Then, we will get a single executable FFmpeg binary!
P.S.: I removed the libass support from the configuration, because libass depends on Fontconfig lib which I only have dynamic library available. I'll put the libass support back once I figured out how to make a static library of fontconfig.
Thanks.