
mov_compress.sh -> does max video compression and reduces size of video to greater extent while using 100% of cpu. mov_size.sh -> does moderate video compression and reduces size of video to medium and satisfactory extent , cpu usage is less.
30 lines
1.0 KiB
Bash
30 lines
1.0 KiB
Bash
#!/bin/bash
|
|
|
|
# Directory containing the original movies
|
|
input_directory="/home/arul/Movies"
|
|
|
|
# Directory to save the converted movies
|
|
output_directory="/home/arul/Movie-Rendered-output"
|
|
|
|
# Create the output directory if it doesn't exist
|
|
mkdir -p "$output_directory"
|
|
|
|
# Loop through all movie files in the input directory
|
|
for input_file in "$input_directory"/*; do
|
|
# Get the resolution of the input file
|
|
resolution=$(ffmpeg -i "$input_file" 2>&1 | grep -oP 'Stream.*Video.* \K[0-9]+x[0-9]+')
|
|
|
|
# Check if the resolution is greater than 720p (1280x720)
|
|
width=$(echo $resolution | cut -d'x' -f1)
|
|
height=$(echo $resolution | cut -d'x' -f2)
|
|
|
|
if [[ "$width" -gt 1280 || "$height" -gt 720 ]]; then
|
|
# Construct the output file path
|
|
output_file="$output_directory/$(basename "$input_file")"
|
|
|
|
# Convert the movie to 720p with aesthetic filters
|
|
ffmpeg -i "$input_file" -vf "scale=1280:720,eq=contrast=1.1:brightness=0.05:saturation=1.2" -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k "$output_file"
|
|
fi
|
|
done
|
|
|