From 902521ffc3c92ad422dd095a67236a07c409b822 Mon Sep 17 00:00:00 2001 From: ThatLinuxFan <9904667+NodeMixaholic@users.noreply.github.com> Date: Fri, 19 Jan 2024 15:47:39 -0600 Subject: [PATCH] The Stability Update 1. Add a hacky fix for the non-mutliple-of-two width/height scenerio. --- keywords2images.sh | 29 ++++++++++++++++++++++++----- make_video.sh | 5 ----- make_video_premade_script.sh | 5 ----- renderer.sh | 15 +++++++++++++++ scripter.sh | 6 +----- scripter_premade.sh | 6 +----- 6 files changed, 41 insertions(+), 25 deletions(-) diff --git a/keywords2images.sh b/keywords2images.sh index 6900453..cf2faea 100644 --- a/keywords2images.sh +++ b/keywords2images.sh @@ -5,12 +5,31 @@ done < script-keywords.txt # Navigate to the img/ directory cd img/ -# Find and delete images not divisible by 2 -find . -type f -exec bash -c 'if [ $(identify -format "%h" "{}")%2 -ne 0 ]; then rm "{}"; fi' \; - - # Find files with 0 size find . -type f -size 0 -delete -# Return to the original directory (optional) +# Return to the original directory cd .. + +# Add our images to the concat file. +ls -1v img/* | while IFS= read -r file; do + echo "file '$(echo "$file" | sed "s/'/\\\'/g")'" +done > concat.txt +sed -i '/\\/d' concat.txt + +# Resize images in img folder to multiple of 2. + +for image in img/*; do + # Use identify to get the width and height of the image + width=$(identify -format "%w" "$image") + height=$(identify -format "%h" "$image") + + # Calculate the nearest multiple of 2 for width and height + new_width=$((width + (2 - (width % 2)) % 2)) + new_height=$((height + (2 - (height % 2)) % 2)) + + # Resize the image to the nearest multiple of 2 + convert "$image" -resize "${new_width}x${new_height}" "$image" + + echo "Resized $image to ${new_width}x${new_height}" +done \ No newline at end of file diff --git a/make_video.sh b/make_video.sh index fa73d6d..559db03 100644 --- a/make_video.sh +++ b/make_video.sh @@ -1,9 +1,4 @@ ./scripter.sh "$1" ./keywords2images.sh espeak -f script.txt -w voice.wav -ls -1v img/* | while IFS= read -r file; do - echo "file '$(echo "$file" | sed "s/'/\\\'/g")'" -done > concat.txt -sed -i '/\\/d' concat.txt - ./renderer.sh diff --git a/make_video_premade_script.sh b/make_video_premade_script.sh index c57e1a3..c2ebaab 100644 --- a/make_video_premade_script.sh +++ b/make_video_premade_script.sh @@ -1,9 +1,4 @@ ./scripter_premade.sh "$1" ./keywords2images.sh espeak -f script.txt -w voice.wav -ls -1v img/* | while IFS= read -r file; do - echo "file '$(echo "$file" | sed "s/'/\\\'/g")'" -done > concat.txt -sed -i '/\\/d' concat.txt - ./renderer.sh diff --git a/renderer.sh b/renderer.sh index fbe1fa7..bd2c4ea 100644 --- a/renderer.sh +++ b/renderer.sh @@ -1,3 +1,18 @@ +# Specify the directory containing your images +image_directory="img/" + +# Iterate over each image in the directory +for image in "$image_directory"/*; do + # Use identify to get the width of the image + width=$(identify -format "%w" "$image") + + # Check if the width is not divisible by 2 + if [ $((width % 2)) -ne 0 ]; then + echo "Deleting $image (width: $width)" + rm "$image" + fi +done + total_frames=$(wc -l < concat.txt) # Count the total number of frames in concat.txt voice_length=$(ffprobe -i voice.wav -show_entries format=duration -v quiet -of csv="p=0") # Get the length of voice.wav diff --git a/scripter.sh b/scripter.sh index 582b8b6..12825ac 100644 --- a/scripter.sh +++ b/scripter.sh @@ -4,8 +4,4 @@ awk '{ print $4 }' script.txt >> script-keywords.txt awk '{ print $6 }' script.txt >> script-keywords.txt mkdir img -rm img/* -while IFS= read -r line; do - ./image-finder.sh "$line" -done < script-keywords.txt -find img -type f -size 0 -delete +rm img/* \ No newline at end of file diff --git a/scripter_premade.sh b/scripter_premade.sh index c87942e..dbe6087 100644 --- a/scripter_premade.sh +++ b/scripter_premade.sh @@ -4,8 +4,4 @@ awk '{ print $4 }' script.txt >> script-keywords.txt awk '{ print $6 }' script.txt >> script-keywords.txt mkdir img -rm img/* -while IFS= read -r line; do - ./image-finder.sh "$line" -done < script-keywords.txt -find img -type f -size 0 -delete +rm img/* \ No newline at end of file