From f499dfad969696f40a8c013bf670de8644a03e58 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Wed, 20 Jan 2021 13:27:29 -0500 Subject: [PATCH] Add script to fix one-sided audio channel in a vid --- aliases | 26 +++++------------- bin/fix-audio-in-one-channel | 51 ++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 bin/fix-audio-in-one-channel diff --git a/aliases b/aliases index 27330db..a3970f5 100644 --- a/aliases +++ b/aliases @@ -173,16 +173,18 @@ dl_youtube_playlist() { shift 3 local opts="$@" - if [[ $url == "" || $dir_name == "" ]]; then - error "Format: cmd \n" + if [[ $url == "" ]]; then + error "Format: cmd \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" diff --git a/bin/fix-audio-in-one-channel b/bin/fix-audio-in-one-channel new file mode 100644 index 0000000..4b13c1e --- /dev/null +++ b/bin/fix-audio-in-one-channel @@ -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 ${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" +