Add script to fix one-sided audio channel in a vid

This commit is contained in:
Michael Campagnaro 2021-01-20 13:27:29 -05:00
parent da7ef55309
commit f499dfad96
2 changed files with 58 additions and 19 deletions

26
aliases
View File

@ -173,16 +173,18 @@ dl_youtube_playlist() {
shift 3
local opts="$@"
if [[ $url == "" || $dir_name == "" ]]; then
error "Format: cmd <url> <directory name> <optional args>\n"
if [[ $url == "" ]]; then
error "Format: cmd <url> <directory name (optional)> <optional args>\n"
return
fi
opts+=" --all-subs --embed-subs"
make_vid_dir_and_cd_into $url "$dir_name"
if [[ $? -ne 0 ]]; then
return
if [[ $dir_name != "" ]]; then
make_vid_dir_and_cd_into $url "$dir_name"
if [[ $? -ne 0 ]]; then
return
fi
fi
printf "${BOLD}Downloading playlist${NORMAL}\n"
@ -351,14 +353,6 @@ dl_instagram_vid_and_hflip() {
rm $temp_name
}
activate_virtualenv() {
if [ -f venv/bin/activate ]; then . venv/bin/activate;
elif [ -f ../venv/bin/activate ]; then . ../venv/bin/activate;
elif [ -f ../../venv/bin/activate ]; then . ../../venv/bin/activate;
elif [ -f ../../../venv/bin/activate ]; then . ../../../venv/bin/activate;
fi
}
###################################
# Git Functions
###################################
@ -464,12 +458,6 @@ br() {
b $@ ; r
}
alias bd='if [ -f build ]; then ./build -data 1 ; else test -f build.sh && ./build.sh -data 1 ; fi'
alias bbd='if [ -f build ]; then ./build -o 1 -data 1 ; else test -f build.sh && ./build.sh -o 1 -data 1 ; fi'
#alias bl='brew link --overwrite'
#lias bld='brew link --overwrite --dry-run'
alias bower='noglob bower'
if [[ "${platform,,}" == *'ming'* ]]; then
_checksum() {
local algo="$1"

View File

@ -0,0 +1,51 @@
#!/usr/bin/env bash
# Use this to fix the audio of a video that has audio in only the left or right
# channel. This does not re-encode the video.
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 "\n${BOLD}Usage: $0 <filename> <optional output name>${NORMAL}\n"
exit 1
fi
filename=$(basename -- "$1")
extension="${filename##*.}"
filename="${filename%.*}"
output_name="$2"
if [[ $output_name == "" ]]; then
output="${filename}_repaired_audio.$extension"
else
output="${output_name}.$extension"
fi
printf "\n${YELLOW}${BOLD}Repairing audio in $filename.$extension | output: $output${NORMAL}\n"
ffmpeg -i "$filename.$extension" -c:v copy -ac 1 "$output"
printf "\n${GREEN}${BOLD}Done repairing audio in $filename.$extension | output: $output${NORMAL}\n\n"