Created
May 3, 2025 16:21
-
-
Save kabirnayeem99/ba29212612cf3fa23ed525667039f94d to your computer and use it in GitHub Desktop.
FFMPEG Script to Speed Up Video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
display_error() { | |
gum style --foreground 1 "β $1" | |
} | |
display_message() { | |
local color="$1" | |
local message="$2" | |
gum style --foreground "$color" "$message" | |
} | |
validate_input_file() { | |
local input_file="$1" | |
if [ ! -f "$input_file" ]; then | |
display_error "Input file does not exist! β" | |
exit 1 | |
fi | |
} | |
generate_output_file_name() { | |
local input_file="$1" | |
echo "${input_file%.*}_speed-up.${input_file##*.}" | |
} | |
process_video() { | |
local input_file="$1" | |
local output_file="$2" | |
gum style --foreground 34 --border-foreground 34 --border double \ | |
--align center --width 50 --margin "1 2" --padding "2 4" \ | |
"π¬ Processing video..." # Display a nice header with gum | |
gum spin --title "Processing..." -- gum exec ffmpeg -i "$input_file" -filter:v "setpts=PTS/4" -an -loglevel quiet "$output_file" | |
} | |
display_completion_message() { | |
local output_file="$1" | |
gum style --foreground 2 --border-foreground 2 --border double \ | |
--align center --width 50 --margin "1 2" --padding "2 4" \ | |
"β Video processing complete. Output saved as $output_file. π" | |
} | |
main() { | |
if [ -z "$1" ]; then | |
display_error "Usage: $0 <input_file> π" | |
exit 1 | |
fi | |
input_file="$1" | |
validate_input_file "$input_file" | |
output_file=$(generate_output_file_name "$input_file") | |
process_video "$input_file" "$output_file" | |
display_completion_message "$output_file" | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment