Skip to content

Instantly share code, notes, and snippets.

@kabirnayeem99
Created May 3, 2025 16:21
Show Gist options
  • Save kabirnayeem99/ba29212612cf3fa23ed525667039f94d to your computer and use it in GitHub Desktop.
Save kabirnayeem99/ba29212612cf3fa23ed525667039f94d to your computer and use it in GitHub Desktop.
FFMPEG Script to Speed Up Video
#!/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