From d7977096a724f6f13752221d701c0e3ca242340c Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Wed, 2 Aug 2023 15:11:25 -0400 Subject: [PATCH] Add trim-audio and add-audio-to-video scripts --- dotfiles/bin/add-audio-to-video | 58 +++++++++++++++++++++++++++++++++ dotfiles/bin/trim-audio | 51 +++++++++++++++++++++++++++++ dotfiles/bin/trim-video | 5 +-- dotfiles/bin/trim-video-fast | 8 ++--- 4 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 dotfiles/bin/add-audio-to-video create mode 100644 dotfiles/bin/trim-audio diff --git a/dotfiles/bin/add-audio-to-video b/dotfiles/bin/add-audio-to-video new file mode 100644 index 0000000..1c1b798 --- /dev/null +++ b/dotfiles/bin/add-audio-to-video @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Re-encodes the video with a new primary audio channel. + +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 + +vid_filename=$(basename -- "$1") +audio_filename=$(basename -- "$2") +output_name="$3" + +if [[ $vid_filename == "" || $audio_filename == "" || $output_name == "" ]]; then + printf "${BOLD}${RED}Usage: add-audio-to-video