Add a script that removes audio from a video

This commit is contained in:
Michael Campagnaro 2023-03-16 12:59:23 -04:00
parent 08a26b6716
commit 4464e4f681
8 changed files with 77 additions and 32 deletions

44
aliases
View File

@ -36,11 +36,6 @@ error() {
printf "${BOLD}${RED}$1${NORMAL}\n" printf "${BOLD}${RED}$1${NORMAL}\n"
} }
abort() {
error "\nAborting..."
exit 1
}
reload() { reload() {
test -f ~/.env.loader && . ~/.env.loader test -f ~/.env.loader && . ~/.env.loader
} }
@ -217,7 +212,7 @@ check_signature() {
local sig_file="$4" local sig_file="$4"
if [[ $hashes_file == "" || $pem_file == "" || $sig_file == "" ]]; then if [[ $hashes_file == "" || $pem_file == "" || $sig_file == "" ]]; then
error "Format: $0 <hashes file (e.g. sha512 hashes)> <pem file> <sig file>\n" error "Usage: $0 <hashes file (e.g. sha512 hashes)> <pem file> <sig file>"
return return
fi fi
@ -342,7 +337,7 @@ make_vid_dir_and_cd_into() {
error=$? error=$?
if [[ ! $error -eq 0 ]]; then if [[ ! $error -eq 0 ]]; then
error "Error: failed to create directory. Aborting.\n" error "Error: failed to create directory. Aborting."
return 1 return 1
fi fi
@ -359,7 +354,7 @@ download_youtube_vid() {
local opts="$@" local opts="$@"
if [[ $url == "" ]]; then if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional args>\n" error "Usage: $0 <make folder?> <url> <optional args>"
return return
fi fi
@ -405,7 +400,7 @@ download_youtube_vid_and_hflip() {
local opts="$@" local opts="$@"
if [[ $url == "" ]]; then if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional args>\n" error "Usage: $0 <make folder?> <url> <optional args>"
return return
fi fi
if [[ $format == "" ]]; then if [[ $format == "" ]]; then
@ -449,7 +444,7 @@ download_youtube_playlist() {
local opts="$@" local opts="$@"
if [[ $url == "" ]]; then if [[ $url == "" ]]; then
error "Format: $0 <url> <directory name (optional)> <optional args>\n" error "Usage: $0 <url> <directory name (optional)> <optional args>"
return return
fi fi
if [[ $format == "" ]]; then if [[ $format == "" ]]; then
@ -498,7 +493,7 @@ download_twitch_chat() {
local opts="$@" local opts="$@"
if [[ $url == "" ]]; then if [[ $url == "" ]]; then
error "Format: $0 <url>\n" error "Usage: $0 <url>"
return return
fi fi
@ -537,7 +532,7 @@ download_twitch_vid() {
local opts="$@" local opts="$@"
if [[ $url == "" ]]; then if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional args>\n" error "Usage: $0 <make folder?> <url> <optional args>"
return return
fi fi
@ -611,7 +606,7 @@ download_twitch_vid() {
printf "${BOLD}Make sure to delete the original video file${NORMAL}\n" printf "${BOLD}Make sure to delete the original video file${NORMAL}\n"
fi fi
else else
error "Error: Failed to download '$url'\n" error "Error: Failed to download '$url'"
fi fi
if [[ $make_folder == "1" ]]; then if [[ $make_folder == "1" ]]; then
@ -633,7 +628,7 @@ download_vimeo_vid() {
local opts="$@" local opts="$@"
if [[ $url == "" ]]; then if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional args>\n" error "Usage: $0 <make folder?> <url> <optional args>"
return return
fi fi
@ -674,7 +669,7 @@ download_vimeo_vid() {
printf "${BOLD}Make sure to delete the original video file${NORMAL}\n" printf "${BOLD}Make sure to delete the original video file${NORMAL}\n"
fi fi
else else
error "Error: Failed to download '$url'\n" error "Error: Failed to download '$url'"
fi fi
if [[ $make_folder == "1" ]]; then if [[ $make_folder == "1" ]]; then
@ -690,7 +685,7 @@ download_twitter_vid() {
local vid_name="$4" local vid_name="$4"
if [[ $url == "" ]]; then if [[ $url == "" ]]; then
error "Format: $0 <make folder?> <url> <optional filename> <optional args>\n" error "Usage: $0 <make folder?> <url> <optional filename> <optional args>"
return return
fi fi
@ -725,7 +720,7 @@ download_twitter_vid() {
error=$? error=$?
if [[ $error -eq 1 ]]; then if [[ $error -eq 1 ]]; then
error "Error: Failed to download '$url'\n" error "Error: Failed to download '$url'"
fi fi
if [[ $make_folder == "1" ]]; then if [[ $make_folder == "1" ]]; then
@ -739,7 +734,7 @@ download_mp4() {
local filename="$2" local filename="$2"
if [[ $url == "" || $filename == "" ]]; then if [[ $url == "" || $filename == "" ]]; then
error "Format: $0 <url> <filename>\n" error "Usage: $0 <url> <filename>"
return return
fi fi
@ -749,7 +744,7 @@ download_mp4() {
curl "$url" -o $temp_name curl "$url" -o $temp_name
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
error "Error: failed to download.\n" error "Error: failed to download."
return return
fi fi
@ -762,7 +757,7 @@ download_from_m3u8() {
local filename="$2" local filename="$2"
if [[ $m3u8_path == "" || $filename == "" ]]; then if [[ $m3u8_path == "" || $filename == "" ]]; then
error "Format: $0 <m3u8 path> <filename>\n" error "Usage: $0 <m3u8 path> <filename>"
return return
fi fi
@ -770,7 +765,7 @@ download_from_m3u8() {
ffmpeg.exe -protocol_whitelist file,https,crypto,tls,tcp -i $m3u8_path -acodec copy -vcodec copy "${filename}.mp4" ffmpeg.exe -protocol_whitelist file,https,crypto,tls,tcp -i $m3u8_path -acodec copy -vcodec copy "${filename}.mp4"
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
error "Error: failed to download.\n" error "Error: failed to download."
return return
fi fi
@ -783,7 +778,7 @@ download_instagram_vid_and_hflip() {
local filename="$2" local filename="$2"
if [[ $url == "" || $filename == "" ]]; then if [[ $url == "" || $filename == "" ]]; then
error "Format: $0 <url> <filename>\n" error "Usage: $0 <url> <filename>"
return return
fi fi
@ -793,7 +788,7 @@ download_instagram_vid_and_hflip() {
curl "$url" -o $temp_name curl "$url" -o $temp_name
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
error "Error: failed to download.\n" error "Error: failed to download."
return return
fi fi
@ -876,7 +871,7 @@ function _compress_video_hard() {
local name="$1" local name="$1"
local out="$2" local out="$2"
if [[ name == "" || out == "" ]]; then if [[ name == "" || out == "" ]]; then
error "Format: cmd <source> <dest>\n" error "Usage: cmd <source> <dest>"
return return
fi fi
# 0=cpu, 1=gpu # 0=cpu, 1=gpu
@ -1003,6 +998,7 @@ alias gmffs='git merge --ff-only --squash'
alias gmtheirs='git merge -Xtheirs' alias gmtheirs='git merge -Xtheirs'
alias gp='git push' alias gp='git push'
alias gpa='git push --all && echo "pushing tags..." && git push --tags' alias gpa='git push --all && echo "pushing tags..." && git push --tags'
alias gpaf='git push --all -f && echo "pushing tags..." && git push --tags -f'
alias gpf='git push -f' alias gpf='git push -f'
alias gpff='git pull --ff-only' alias gpff='git pull --ff-only'
alias gplu='git pull --set-upstream origin HEAD' alias gplu='git pull --set-upstream origin HEAD'

View File

@ -29,7 +29,7 @@ else
fi fi
if [[ $1 == "" || $2 == "" ]]; then if [[ $1 == "" || $2 == "" ]]; then
printf "${BOLD}${RED}Format: $0 <filename> <bitrate, e.g. \"4000k\"> <optional output name>${NORMAL}\n" printf "${BOLD}${RED}Usage: $0 <filename> <bitrate, e.g. \"4000k\"> <optional output name>${NORMAL}\n"
exit 1 exit 1
fi fi

View File

@ -27,7 +27,7 @@ else
fi fi
if [[ $1 == "" || $2 == "" ]]; then if [[ $1 == "" || $2 == "" ]]; then
printf "${BOLD}${RED}Format: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n" printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
exit 1 exit 1
fi fi

View File

@ -27,7 +27,7 @@ else
fi fi
if [[ $1 == "" || $2 == "" ]]; then if [[ $1 == "" || $2 == "" ]]; then
printf "${BOLD}${RED}Format: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n" printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
exit 1 exit 1
fi fi

View File

@ -27,7 +27,7 @@ else
fi fi
if [[ $1 == "" ]]; then if [[ $1 == "" ]]; then
printf "\n${BOLD}Usage: $0 <filename> <optional output name>${NORMAL}\n" printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
exit 1 exit 1
fi fi

View File

@ -29,7 +29,7 @@ else
fi fi
if [[ $1 == "" ]]; then if [[ $1 == "" ]]; then
printf "\n${BOLD}Usage: $0 <filename> <optional output name>${NORMAL}\n" printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
exit 1 exit 1
fi fi

View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
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: $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}_no_audio.$extension"
else
output="${output_name}.$extension"
fi
printf "\n${YELLOW}${BOLD}Removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n"
# -an removes the audio.
ffmpeg -i "$filename.$extension" -c:v copy -an "$output"
printf "\n${GREEN}${BOLD}Done removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n\n"

View File

@ -45,9 +45,9 @@ if has("gui_running") || &t_Co == 256
hi PmenuSel cterm=bold,reverse ctermfg=250 ctermbg=black gui=reverse guifg=#bcbcbc guibg=#0a0a0a hi PmenuSel cterm=bold,reverse ctermfg=250 ctermbg=black gui=reverse guifg=#bcbcbc guibg=#0a0a0a
hi SpecialKey cterm=NONE ctermfg=16 ctermbg=255 gui=NONE guifg=#eeeeee guibg=#0a0a0a hi SpecialKey cterm=NONE ctermfg=16 ctermbg=255 gui=NONE guifg=#eeeeee guibg=#0a0a0a
hi MatchParen cterm=bold ctermfg=white ctermbg=black gui=NONE guifg=#bcbcbc guibg=#454545 hi MatchParen cterm=bold ctermfg=white ctermbg=black gui=NONE guifg=#bcbcbc guibg=#454545
hi CursorLine cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#222222 hi CursorLine cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#111111
hi CursorColumn cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#222222 hi CursorColumn cterm=NONE ctermfg=NONE ctermbg=233 gui=NONE guifg=NONE guibg=#111111
hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=255 gui=NONE guifg=NONE guibg=#222222 " The column line set by colorcolumn hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=255 gui=NONE guifg=NONE guibg=#171717 " The column line set by colorcolumn
hi StatusLine cterm=bold,reverse ctermfg=245 ctermbg=black gui=bold,reverse guifg=#8a8a8a guibg=#0a0a0a hi StatusLine cterm=bold,reverse ctermfg=245 ctermbg=black gui=bold,reverse guifg=#8a8a8a guibg=#0a0a0a
hi StatusLineNC cterm=reverse ctermfg=236 ctermbg=black gui=reverse guifg=#303030 guibg=#0a0a0a hi StatusLineNC cterm=reverse ctermfg=236 ctermbg=black gui=reverse guifg=#303030 guibg=#0a0a0a
hi Visual cterm=reverse ctermfg=250 ctermbg=black gui=reverse guifg=#bcbcbc guibg=#0a0a0a hi Visual cterm=reverse ctermfg=250 ctermbg=black gui=reverse guifg=#bcbcbc guibg=#0a0a0a