Rename volume adjustment scripts
This commit is contained in:
52
dotfiles/bin/analyze-volume
Normal file
52
dotfiles/bin/analyze-volume
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Use this to get a volume report from a video or audio file. You can use this
|
||||
# info manually normalize or increase/decrease the volume using the
|
||||
# change-volume script, supplying it the volume delta you want. Typically you
|
||||
# use the delta from the analysis report this script provides, e.g. if the
|
||||
# max_volume is -5 db then you would call change-volume with a value of 5. I
|
||||
# find that the two pass normalize-audio script works better than this
|
||||
# approach...but it will take longer to run!
|
||||
#
|
||||
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: analyze-volume <video or audio filename>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename="$1"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Analyzing audio in $filename${NORMAL}\n"
|
||||
|
||||
# -vn, -sn, and -dn tells ffmpeg to ignore non-audio streams during the analysis. This speeds things up.
|
||||
cmd="ffmpeg -i \"$filename\" -af volumedetect -vn -sn -dn -f null /dev/null"
|
||||
printf "\n${BOLD}Running: $cmd\n\n${NORMAL}"
|
||||
eval $cmd
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done analyzing audio in $filename\n${NORMAL}"
|
||||
printf "\n${YELLOW}${BOLD}Look at the reported max_volume value. If != 0 then call the change-volume script, passing it the filename, an output name and the delta to bring the volume to 0.\ne.g. if the max_volume is -5 db, then you would pass 5.${NORMAL}\n\n"
|
||||
|
||||
Reference in New Issue
Block a user