parent
9a34944e30
commit
ff50607e6d
@ -0,0 +1,90 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Default to the current directory if none provided
|
||||||
|
# https://stackoverflow.com/a/48829326
|
||||||
|
dir="${1:-.}"
|
||||||
|
|
||||||
|
dbg=$1
|
||||||
|
|
||||||
|
# Colors are fun
|
||||||
|
blk=$(tput setaf 0);red=$(tput setaf 1);grn=$(tput setaf 2)
|
||||||
|
ylw=$(tput setaf 3);blu=$(tput setaf 4);cyn=$(tput setaf 6)
|
||||||
|
wht=$(tput setaf 7);und=$(tput smul);bld=$(tput bold)
|
||||||
|
# Uncoloring is important
|
||||||
|
rst=$(tput sgr0)
|
||||||
|
|
||||||
|
|
||||||
|
function dependencycheck() {
|
||||||
|
which ffmpeg
|
||||||
|
if [[ $? -eq 1 ]]; then
|
||||||
|
die "Dependency check failed. ffmpeg not found."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
major=0;minor=0;
|
||||||
|
function getversion() {
|
||||||
|
# This script was written with 4.4. Other versions may work but are untested
|
||||||
|
#local version=5.5 #`ffmpeg -version | head -n1 | cut -d' ' -f3 | cut -d- -f1`
|
||||||
|
major=`echo $version | cut -d. -f1`
|
||||||
|
minor=`echo $version | cut -d. -f2`
|
||||||
|
}
|
||||||
|
|
||||||
|
function die() {
|
||||||
|
echo -en ${rst}${red}Exiting for: ${rst}
|
||||||
|
echo -e ${rst}${2:-$red}${1}${rst}
|
||||||
|
[[ $dbg != "--dont-die" ]] && exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function warn() {
|
||||||
|
echo -en ${rst}${ylw}Warning: ${rst}
|
||||||
|
echo -e ${rst}${2:-$ylw}${1}${rst}
|
||||||
|
}
|
||||||
|
|
||||||
|
function info() {
|
||||||
|
echo -en ${rst}${blu}Info: ${rst}
|
||||||
|
echo -e ${rst}${2:-$blu}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkversion() {
|
||||||
|
if [[ $major -eq 0 && $minor -eq 0 ]]; then
|
||||||
|
die "version check failed."
|
||||||
|
fi
|
||||||
|
if [[ $major -lt 4 || $major -eq 4 && $minor -lt 4 ]]; then
|
||||||
|
warn "ffmpeg version less than 4.4 ($major.$minor). This script may work but it has not been tested"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# trap ctrl-c and call ctrl_c()
|
||||||
|
# https://rimuhosting.com/knowledgebase/linux/misc/trapping-ctrl-c-in-bash
|
||||||
|
trap ctrl_c INT
|
||||||
|
function ctrl_c() {
|
||||||
|
tput cnorm
|
||||||
|
echo "${rst}${red}CTRL+C Detected, exiting.${rst}"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertfile () {
|
||||||
|
# https://stackoverflow.com/a/62520505
|
||||||
|
local file=$1
|
||||||
|
local filename=`echo $file | rev | cut -d. -f2- | rev`
|
||||||
|
ffmpeg -i $filename.flac -c:v copy -c:a alac $filename.m4a
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################
|
||||||
|
# _| _| _| _| #
|
||||||
|
# _|_| _|_| _|_|_| _|_|_| _|_|_| _| #
|
||||||
|
# _| _| _| _| _| _| _| _| _| _| #
|
||||||
|
# _| _| _| _| _| _| _| _| _| #
|
||||||
|
# _| _| _|_|_| _|_|_| _| _|_|_| _| _| _| #
|
||||||
|
# _| _|_|_| #
|
||||||
|
# _|_| _| #
|
||||||
|
###############################################################
|
||||||
|
|
||||||
|
|
||||||
|
dependencycheck
|
||||||
|
getversion
|
||||||
|
checkversion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue