@@ -926,6 +926,12 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
926926 EXTRA_VERSION=" ${FFMPEG_VERSION} "
927927fi
928928
929+ if [ -d " $CWD /.git" ]; then
930+ echo -e " \nTemporarily moving .git dir to .git.bak to workaround ffmpeg build bug" # causing ffmpeg version number to be wrong
931+ mv " $CWD /.git" " $CWD /.git.bak"
932+ # if build fails below, .git will remain in the wrong place...
933+ fi
934+
929935build " ffmpeg" " $FFMPEG_VERSION "
930936download " https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/$FFMPEG_VERSION .tar.gz" " FFmpeg-release-$FFMPEG_VERSION .tar.gz"
931937# shellcheck disable=SC2086
@@ -947,9 +953,19 @@ download "https://github.com/FFmpeg/FFmpeg/archive/refs/heads/release/$FFMPEG_VE
947953execute make -j $MJOBS
948954execute make install
949955
950- INSTALL_FOLDER=" /usr/bin"
956+ if [ -d " $CWD /.git.bak" ]; then
957+ mv " $CWD /.git.bak" " $CWD /.git"
958+ fi
959+
960+ INSTALL_FOLDER=" /usr" # not recommended, overwrites system ffmpeg package
951961if [[ " $OSTYPE " == " darwin" * ]]; then
952- INSTALL_FOLDER=" /usr/local/bin"
962+ INSTALL_FOLDER=" /usr/local"
963+ else
964+ if [ -d " $HOME /.local" ]; then # systemd-standard user path
965+ INSTALL_FOLDER=" $HOME /.local"
966+ elif [ -d " /usr/local" ]; then
967+ INSTALL_FOLDER=" /usr/local"
968+ fi
953969fi
954970
955971verify_binary_type
@@ -961,34 +977,37 @@ echo "- ffprobe: $WORKSPACE/bin/ffprobe"
961977echo " - ffplay: $WORKSPACE /bin/ffplay"
962978echo " "
963979
980+ INSTALL_NOW=0
964981if [[ " $AUTOINSTALL " == " yes" ]]; then
965- if command_exists " sudo" ; then
966- sudo cp " $WORKSPACE /bin/ffmpeg" " $INSTALL_FOLDER /ffmpeg"
967- sudo cp " $WORKSPACE /bin/ffprobe" " $INSTALL_FOLDER /ffprobe"
968- sudo cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /ffplay"
969- echo " Done. FFmpeg is now installed to your system."
970- else
971- cp " $WORKSPACE /bin/ffmpeg" " $INSTALL_FOLDER /ffmpeg"
972- cp " $WORKSPACE /bin/ffprobe" " $INSTALL_FOLDER /ffprobe"
973- cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /ffplay"
974- echo " Done. FFmpeg is now installed to your system."
975- fi
982+ INSTALL_NOW=1
976983elif [[ ! " $SKIPINSTALL " == " yes" ]]; then
977984 read -r -p " Install these binaries to your $INSTALL_FOLDER folder? Existing binaries will be replaced. [Y/n] " response
978985 case $response in
979- [yY][eE][sS] | [yY])
980- if command_exists " sudo" ; then
981- sudo cp " $WORKSPACE /bin/ffmpeg" " $INSTALL_FOLDER /ffmpeg"
982- sudo cp " $WORKSPACE /bin/ffprobe" " $INSTALL_FOLDER /ffprobe"
983- sudo cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /ffplay"
984- else
985- cp " $WORKSPACE /bin/ffmpeg" " $INSTALL_FOLDER /ffmpeg"
986- cp " $WORKSPACE /bin/ffprobe" " $INSTALL_FOLDER /ffprobe"
987- cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /ffplay"
988- fi
989- echo " Done. FFmpeg is now installed to your system."
986+ (" " | [yY][eE][sS] | [yY])
987+ INSTALL_NOW=1
990988 ;;
991989 esac
992990fi
993991
992+ if [ " $INSTALL_NOW " = 1 ]; then
993+ if command_exists " sudo" && [[ $INSTALL_FOLDER == /usr* ]]; then
994+ sudo cp " $WORKSPACE /bin/ffmpeg" " $INSTALL_FOLDER /bin/ffmpeg"
995+ sudo cp " $WORKSPACE /bin/ffprobe" " $INSTALL_FOLDER /bin/ffprobe"
996+ sudo cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /bin/ffplay"
997+ if [ $MANPAGES = 1 ]; then
998+ sudo mkdir -p " $INSTALL_FOLDER /share/man/man1"
999+ sudo cp " $WORKSPACE /share/man/man1" /ff* " $INSTALL_FOLDER /share/man/man1"
1000+ fi
1001+ else
1002+ cp " $WORKSPACE /bin/ffmpeg" " $INSTALL_FOLDER /bin/ffmpeg"
1003+ cp " $WORKSPACE /bin/ffprobe" " $INSTALL_FOLDER /bin/ffprobe"
1004+ cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /bin/ffplay"
1005+ if [ $MANPAGES = 1 ]; then
1006+ mkdir -p " $INSTALL_FOLDER /share/man/man1"
1007+ cp " $WORKSPACE /share/man/man1" /ff* " $INSTALL_FOLDER /share/man/man1"
1008+ fi
1009+ fi
1010+ echo " Done. FFmpeg is now installed to your system."
1011+ fi
1012+
9941013exit 0
0 commit comments