From 4464e4f681af323051bb294e3d75eb099a1684bb Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Thu, 16 Mar 2023 12:59:23 -0400 Subject: [PATCH] Add a script that removes audio from a video --- aliases | 44 +++++++++++++--------------- bin/convert-video-avi-to-mp4 | 2 +- bin/convert-video-flv-to-mp4 | 2 +- bin/convert-video-mkv-to-mp4 | 2 +- bin/fix-audio-in-one-channel | 2 +- bin/normalize-video-volume | 2 +- bin/remove-audio-from-video | 49 ++++++++++++++++++++++++++++++++ vim/colors/campo-dark-simple.vim | 6 ++-- 8 files changed, 77 insertions(+), 32 deletions(-) create mode 100644 bin/remove-audio-from-video diff --git a/aliases b/aliases index 57838d3..2941683 100644 --- a/aliases +++ b/aliases @@ -36,11 +36,6 @@ error() { printf "${BOLD}${RED}$1${NORMAL}\n" } -abort() { - error "\nAborting..." - exit 1 -} - reload() { test -f ~/.env.loader && . ~/.env.loader } @@ -217,7 +212,7 @@ check_signature() { local sig_file="$4" if [[ $hashes_file == "" || $pem_file == "" || $sig_file == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi @@ -342,7 +337,7 @@ make_vid_dir_and_cd_into() { error=$? if [[ ! $error -eq 0 ]]; then - error "Error: failed to create directory. Aborting.\n" + error "Error: failed to create directory. Aborting." return 1 fi @@ -359,7 +354,7 @@ download_youtube_vid() { local opts="$@" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi @@ -405,7 +400,7 @@ download_youtube_vid_and_hflip() { local opts="$@" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi if [[ $format == "" ]]; then @@ -449,7 +444,7 @@ download_youtube_playlist() { local opts="$@" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi if [[ $format == "" ]]; then @@ -498,7 +493,7 @@ download_twitch_chat() { local opts="$@" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi @@ -537,7 +532,7 @@ download_twitch_vid() { local opts="$@" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi @@ -611,7 +606,7 @@ download_twitch_vid() { printf "${BOLD}Make sure to delete the original video file${NORMAL}\n" fi else - error "Error: Failed to download '$url'\n" + error "Error: Failed to download '$url'" fi if [[ $make_folder == "1" ]]; then @@ -633,7 +628,7 @@ download_vimeo_vid() { local opts="$@" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi @@ -674,7 +669,7 @@ download_vimeo_vid() { printf "${BOLD}Make sure to delete the original video file${NORMAL}\n" fi else - error "Error: Failed to download '$url'\n" + error "Error: Failed to download '$url'" fi if [[ $make_folder == "1" ]]; then @@ -690,7 +685,7 @@ download_twitter_vid() { local vid_name="$4" if [[ $url == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi @@ -725,7 +720,7 @@ download_twitter_vid() { error=$? if [[ $error -eq 1 ]]; then - error "Error: Failed to download '$url'\n" + error "Error: Failed to download '$url'" fi if [[ $make_folder == "1" ]]; then @@ -739,7 +734,7 @@ download_mp4() { local filename="$2" if [[ $url == "" || $filename == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi @@ -749,7 +744,7 @@ download_mp4() { curl "$url" -o $temp_name if [[ $? -ne 0 ]]; then - error "Error: failed to download.\n" + error "Error: failed to download." return fi @@ -762,7 +757,7 @@ download_from_m3u8() { local filename="$2" if [[ $m3u8_path == "" || $filename == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return 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" if [[ $? -ne 0 ]]; then - error "Error: failed to download.\n" + error "Error: failed to download." return fi @@ -783,7 +778,7 @@ download_instagram_vid_and_hflip() { local filename="$2" if [[ $url == "" || $filename == "" ]]; then - error "Format: $0 \n" + error "Usage: $0 " return fi @@ -793,7 +788,7 @@ download_instagram_vid_and_hflip() { curl "$url" -o $temp_name if [[ $? -ne 0 ]]; then - error "Error: failed to download.\n" + error "Error: failed to download." return fi @@ -876,7 +871,7 @@ function _compress_video_hard() { local name="$1" local out="$2" if [[ name == "" || out == "" ]]; then - error "Format: cmd \n" + error "Usage: cmd " return fi # 0=cpu, 1=gpu @@ -1003,6 +998,7 @@ alias gmffs='git merge --ff-only --squash' alias gmtheirs='git merge -Xtheirs' alias gp='git push' 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 gpff='git pull --ff-only' alias gplu='git pull --set-upstream origin HEAD' diff --git a/bin/convert-video-avi-to-mp4 b/bin/convert-video-avi-to-mp4 index 4944f03..bbbe574 100644 --- a/bin/convert-video-avi-to-mp4 +++ b/bin/convert-video-avi-to-mp4 @@ -29,7 +29,7 @@ else fi if [[ $1 == "" || $2 == "" ]]; then - printf "${BOLD}${RED}Format: $0 ${NORMAL}\n" + printf "${BOLD}${RED}Usage: $0 ${NORMAL}\n" exit 1 fi diff --git a/bin/convert-video-flv-to-mp4 b/bin/convert-video-flv-to-mp4 index 6074570..b54b949 100644 --- a/bin/convert-video-flv-to-mp4 +++ b/bin/convert-video-flv-to-mp4 @@ -27,7 +27,7 @@ else fi if [[ $1 == "" || $2 == "" ]]; then - printf "${BOLD}${RED}Format: $0 ${NORMAL}\n" + printf "${BOLD}${RED}Usage: $0 ${NORMAL}\n" exit 1 fi diff --git a/bin/convert-video-mkv-to-mp4 b/bin/convert-video-mkv-to-mp4 index d83aeda..77863d4 100644 --- a/bin/convert-video-mkv-to-mp4 +++ b/bin/convert-video-mkv-to-mp4 @@ -27,7 +27,7 @@ else fi if [[ $1 == "" || $2 == "" ]]; then - printf "${BOLD}${RED}Format: $0 ${NORMAL}\n" + printf "${BOLD}${RED}Usage: $0 ${NORMAL}\n" exit 1 fi diff --git a/bin/fix-audio-in-one-channel b/bin/fix-audio-in-one-channel index 4b13c1e..17c5e00 100644 --- a/bin/fix-audio-in-one-channel +++ b/bin/fix-audio-in-one-channel @@ -27,7 +27,7 @@ else fi if [[ $1 == "" ]]; then - printf "\n${BOLD}Usage: $0 ${NORMAL}\n" + printf "${BOLD}${RED}Usage: $0 ${NORMAL}\n" exit 1 fi diff --git a/bin/normalize-video-volume b/bin/normalize-video-volume index 634b514..2580a25 100644 --- a/bin/normalize-video-volume +++ b/bin/normalize-video-volume @@ -29,7 +29,7 @@ else fi if [[ $1 == "" ]]; then - printf "\n${BOLD}Usage: $0 ${NORMAL}\n" + printf "${BOLD}${RED}Usage: $0 ${NORMAL}\n" exit 1 fi diff --git a/bin/remove-audio-from-video b/bin/remove-audio-from-video new file mode 100644 index 0000000..a331e68 --- /dev/null +++ b/bin/remove-audio-from-video @@ -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 ${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" + diff --git a/vim/colors/campo-dark-simple.vim b/vim/colors/campo-dark-simple.vim index 2d846ca..a091ac4 100644 --- a/vim/colors/campo-dark-simple.vim +++ b/vim/colors/campo-dark-simple.vim @@ -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 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 CursorLine 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=#222222 - hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=255 gui=NONE guifg=NONE guibg=#222222 " The column line set by colorcolumn + 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=#111111 + 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 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