52 lines
1.2 KiB
Plaintext
52 lines
1.2 KiB
Plaintext
|
#!/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"
|
||
|
|