Improve video input frames detection
authorHugo Villeneuve <hugo@hugovil.com>
Sun, 8 Oct 2023 02:36:34 +0000 (22:36 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Sun, 8 Oct 2023 18:00:24 +0000 (14:00 -0400)
Will also work with frames with leading zeros in their name.

fgen.sh

diff --git a/fgen.sh b/fgen.sh
index 6cc7db6..f2c961f 100755 (executable)
--- a/fgen.sh
+++ b/fgen.sh
@@ -130,13 +130,19 @@ function insert_empty_frames()
 
 function generate_video()
 {
+    local png_files
+
     if which ffmpeg 1> /dev/null 2>&1; then
-        if [ -f ${dest}/${group}-f1.png ]; then
+        set +e
+        png_files=$(ls ${dest}/${group}-f*.png 2> /dev/null)
+        set -e
+
+        if [ x"${png_files}" != x"" ]; then
             log_dbg "generate_video start"
             if [ ${dry_run} -eq 1 ]; then
                 touch ${dest}/${group}.mp4
             else
-                ffmpeg ${FFMPEG_OPTS} -r ${fps} -start_number 1 -i ${dest}/${group}-f%d.png ${dest}/${group}.mp4
+                ffmpeg ${FFMPEG_OPTS} -r ${fps} -pattern_type glob -i "${dest}/${group}-f*.png" ${dest}/${group}.mp4
             fi
 
             log_dbg "generate_video: end"