From 73cacf0f1a1dbf671c5c5c53eb2dfa6939352a7b Mon Sep 17 00:00:00 2001 From: arul Date: Sun, 30 Jun 2024 19:41:09 +0000 Subject: [PATCH] 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. --- mov_compress.sh | 31 +++++++++++++++++++++++++++++++ mov_size.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 mov_compress.sh create mode 100644 mov_size.sh diff --git a/mov_compress.sh b/mov_compress.sh new file mode 100644 index 0000000..dd89a73 --- /dev/null +++ b/mov_compress.sh @@ -0,0 +1,31 @@ +#!/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 + diff --git a/mov_size.sh b/mov_size.sh new file mode 100644 index 0000000..6bda37f --- /dev/null +++ b/mov_size.sh @@ -0,0 +1,29 @@ +#!/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 +