Compare commits

..

No commits in common. "4fb7e6cf37bd7d8f3b9578ab0beaf5aa7e52aa40" and "6555d9d35591c95f3d6e9dbb3f94f4d41cbede6d" have entirely different histories.

3 changed files with 16 additions and 51 deletions

View File

@ -25,33 +25,24 @@ else
NORMAL="" NORMAL=""
fi fi
filename="$1" filename=$(basename -- "$1")
output_name_with_extension="$2" output_name="$2"
start_time="$3" start_time="$3"
end_time="$4" end_time="$4"
if [[ $filename == "" || $output_name_with_extension == "" || $start_time == "" ]]; then if [[ $filename == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
printf "${BOLD}${RED}Usage: trim-audio <filename> <output name w/ extension> <start time HH:MM:SS> <optional: end time HH:MM:SS, set to empty string or 0 for no value>${NORMAL}\n" printf "${BOLD}${RED}Usage: trim-audio <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
exit 1 exit 1
fi fi
timing_args="" extension="${filename##*.}"
if [[ $start_time != "" ]]; then filename="${filename%.*}"
timing_args="-ss $start_time " output="${output_name}.$extension"
fi timing_args="-ss $start_time -to $end_time"
if [[ $end_time != "" ]]; then
if [[ $start_time == "0" && $end_time == "0" ]]; then
# We treat a start and end with 0 values as no op.
timing_args=""
elif [[ $end_time != "0" ]]; then
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
timing_args+="-to $end_time"
fi
fi
printf "\n${YELLOW}${BOLD}Trimming '$filename' | output: $output_name_with_extension | start: $start_time | end: $end_time${NORMAL}\n" printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename" -map a "$output_name_with_extension" ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename.$extension" -c copy "$output"
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"

View File

@ -30,28 +30,15 @@ output_name="$2"
start_time="$3" start_time="$3"
end_time="$4" end_time="$4"
if [[ $filename == "" || $output_name == "" || $start_time == "" ]]; then if [[ $filename == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
printf "${BOLD}${RED}Usage: trim-video <filename> <output name> <start time HH:MM:SS> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n" printf "${BOLD}${RED}Usage: trim-video <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
exit 1 exit 1
fi fi
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
output="${output_name}.$extension" output="${output_name}.$extension"
timing_args="-ss $start_time -to $end_time"
timing_args=""
if [[ $start_time != "" ]]; then
timing_args="-ss $start_time "
fi
if [[ $end_time != "" ]]; then
if [[ $start_time == "0" && $end_time == "0" ]]; then
# We treat a start and end with 0 values as no op.
timing_args=""
elif [[ $end_time != "0" ]]; then
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
timing_args+="-to $end_time"
fi
fi
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n" printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"

View File

@ -33,28 +33,15 @@ output_name="$2"
start_time="$3" start_time="$3"
end_time="$4" end_time="$4"
if [[ $filename == "" || $output_name == "" || $start_time == "" ]]; then if [[ $filename == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
printf "${BOLD}${RED}Usage: trim-video-fast <filename> <output name> <start time HH:MM:SS> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n" printf "${BOLD}${RED}Usage: trim-video-fast <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
exit 1 exit 1
fi fi
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
output="${output_name}.$extension" output="${output_name}.$extension"
timing_args="-ss $start_time -to $end_time"
timing_args=""
if [[ $start_time != "" ]]; then
timing_args="-ss $start_time "
fi
if [[ $end_time != "" ]]; then
if [[ $start_time == "0" && $end_time == "0" ]]; then
# We treat a start and end with 0 values as no op.
timing_args=""
elif [[ $end_time != "0" ]]; then
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
timing_args+="-to $end_time"
fi
fi
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n" printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"