ffmpeg-scripts/mov_compress.sh
arul 73cacf0f1a Upload files to "/"
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.
2024-06-30 19:41:09 +00:00

32 lines
1.1 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 using a faster preset
echo "Processing file: $(basename "$input_file")"
time ffmpeg -i "$input_file" -vf "scale=1280:720,eq=contrast=1.1:brightness=0.05:saturation=1.2" \
-c:v libx264 -preset fast -crf 28 -b:v 1500k -c:a aac -b:a 96k "$output_file"
fi
done