Skip to content

Instantly share code, notes, and snippets.

@burakaksoy
Last active September 23, 2024 14:36
Show Gist options
  • Select an option

  • Save burakaksoy/2b42ceec73b42b7c9084af37cb84c0a8 to your computer and use it in GitHub Desktop.

Select an option

Save burakaksoy/2b42ceec73b42b7c9084af37cb84c0a8 to your computer and use it in GitHub Desktop.
A Quick video speedup bash script for ALL mp4 files in a directory using 'mencoder'
#!/bin/bash
# Speed Up Video Script for All .mp4 Files in Directory
# This script speeds up all video files in the current directory using mencoder.
#
# Install:
# sudo apt install mencoder
#
# Save this script as: speedup_all_videos.sh
#
# Make it executable with:
# chmod +x speedup_all_videos.sh
#
# Usage example:
# ./speedup_all_videos.sh 6
#
# Idea Based on: https://superuser.com/a/160448/1461742
# Pure command:
# mencoder input.mp4 -speed 6 -o input-6x.mp4 -ovc copy -nosound
# mencoder input.mp4 -speed 6 -o input-6x.mp4 -ovc copy -oac copy
# Check if the correct number of arguments was provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <speed_scale>"
exit 1
fi
# The speed scale
speed_scale="$1"
# Loop through all .mp4 files in the current directory
for input_file in *.mp4; do
# Extract filename without extension
filename=$(basename -- "$input_file")
extension="${filename##*.}"
filename="${filename%.*}"
# Construct output filename
output_file="${filename}-${speed_scale}x.${extension}"
# Execute mencoder to speed up the video
mencoder "$input_file" -speed "$speed_scale" -o "$output_file" -ovc copy -nosound
echo "Output file created: $output_file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment