Fix bug with missing video for last group
authorHugo Villeneuve <hugo@hugovil.com>
Sat, 7 Oct 2023 03:57:17 +0000 (23:57 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Sat, 7 Oct 2023 15:57:56 +0000 (11:57 -0400)
fgen.sh

diff --git a/fgen.sh b/fgen.sh
index d60da59..9fbd121 100755 (executable)
--- a/fgen.sh
+++ b/fgen.sh
@@ -95,6 +95,18 @@ function get_dup_to()
     echo "${dup}"
 }
 
+function generate_video()
+{
+    if which ffmpeg 1> /dev/null 2>&1; then
+        if [ -f ${dest}/${group}-f1.png ]; then
+            if [ ${dry_run} -eq 0 ]; then
+                # Conversion vidéo:
+                ffmpeg ${FFMPEG_OPTS} -r ${fps} -start_number 1 -i ${dest}/${group}-f%d.png ${dest}/${group}.mp4
+            fi
+        fi
+    fi
+}
+
 print_usage()
 {
     echo "${PROG_NAME} -- Générateur de séquence d'images PNG à partir d'un fichier Photoshop (PSD)."
@@ -218,14 +230,7 @@ if [ ${trames} -eq 1 ]; then
 
         # Only change group if ng is set...
         if [ x"${ng}" != x"" ]; then
-            if which ffmpeg 1> /dev/null 2>&1; then
-                if [ -f ${dest}/${group}-f1.png ]; then
-                    if [ ${dry_run} -eq 0 ]; then
-                        # Conversion vidéo:
-                        ffmpeg ${FFMPEG_OPTS} -r ${fps} -start_number 1 -i ${dest}/${group}-f%d.png ${dest}/${group}.mp4
-                    fi
-                fi
-            fi
+            generate_video
 
             group="${ng}"
             log_dbg "New group: ${ng}"
@@ -286,3 +291,6 @@ if [ ${trames} -eq 1 ]; then
         fi
     done <${layers}
 fi
+
+# Special case for last group...
+generate_video