Improve ffmpeg audio fix scripts
This commit is contained in:
parent
67bd7e4454
commit
159c8cff90
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Use this to fix the audio of a video that has audio in only the left or right
|
# Use this to copy audio from the left channel to the right. This does not re-encode the video.
|
||||||
# channel. This does not re-encode the video.
|
|
||||||
|
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
|
@ -27,7 +26,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 == "" ]]; then
|
if [[ $1 == "" ]]; then
|
||||||
printf "${BOLD}${RED}Usage: fix-audio-in-one-channel <filename> <optional output name>${NORMAL}\n"
|
printf "${BOLD}${RED}Usage: copy-left-audio-channel-to-right <filename> <optional output name>${NORMAL}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -43,9 +42,9 @@ else
|
||||||
output="${output_name}.$extension"
|
output="${output_name}.$extension"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "\n${YELLOW}${BOLD}Repairing audio in $filename.$extension | output: $output${NORMAL}\n"
|
printf "\n${YELLOW}${BOLD}Copy left audio channeel to right channel in $filename.$extension | output: $output${NORMAL}\n"
|
||||||
|
|
||||||
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -ac 1 -map 0 "$output"
|
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -af "pan=stereo|c0=c0|c1=c0" -map 0 "$output"
|
||||||
|
|
||||||
printf "\n${GREEN}${BOLD}Done repairing audio in $filename.$extension | output: $output${NORMAL}\n\n"
|
printf "\n${GREEN}${BOLD}Done copying left audio channel to right channel in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||||
|
|
50
dotfiles/bin/copy-right-audio-channel-to-left
Normal file
50
dotfiles/bin/copy-right-audio-channel-to-left
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Use this to copy audio from the right channel to the left. 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 "${BOLD}${RED}Usage: copy-right-audio-channel-to-left <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}Copy right audio channeel to left channel in $filename.$extension | output: $output${NORMAL}\n"
|
||||||
|
|
||||||
|
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -c:v copy -af "pan=stereo|c0=c1|c1=c1" -map 0 "$output"
|
||||||
|
|
||||||
|
printf "\n${GREEN}${BOLD}Done copying right audio channel to left channel in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user