From e2483c8b18aa2cf29edf5b4e70f26d3c367a41a1 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Fri, 6 Oct 2023 16:10:28 -0400 Subject: [PATCH] Add option to skip frames generation (video only) --- fgen.sh | 75 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/fgen.sh b/fgen.sh index 99bc69d..4fe0634 100755 --- a/fgen.sh +++ b/fgen.sh @@ -15,7 +15,7 @@ main_layer="Layer 558" fps=8 debug=0 - +trames=1 SED=sed # -limit memory 5000mb -limit disk 5gb @@ -90,15 +90,19 @@ print_usage() echo echo "Options:" echo " -d affiche les informations de debug" + echo " -f ne regénère pas les trames, mais uniquement la séquence vidéo" echo " -r nombre de trames par seconde (FPS)" echo " -h affiche ce message d'aide" } -while getopts "dhr:" flag ;do +while getopts "dhfr:" flag ;do case ${flag} in d) debug="1" ;; + f) + trames=0 + ;; r) fps="${OPTARG}" ;; @@ -151,52 +155,53 @@ for tool in convert composite identify; do fi done -identify ${IM_OPS} -verbose -format "label:%l,geometry:%g\n" ${src} > ${layers} - -# Ignore empty labels: -${SED} -i -e /label:,.*/d ${layers} +if [ ${trames} -eq 1 ]; then + identify ${IM_OPS} -verbose -format "label:%l,geometry:%g\n" ${src} > ${layers} -# Extract global frame size: -size=$(get_size "${main_layer}") + # Ignore empty labels: + ${SED} -i -e /label:,.*/d ${layers} -log_dbg "CANVAS SIZE=${size}" + # Extract global frame size: + size=$(get_size "${main_layer}") -# Create background frame: -convert -size ${size} xc:none ${dest}/background.png + log_dbg "CANVAS SIZE=${size}" -# Remove first line (Layer 558): -${SED} -i -e '1d' ${layers} + # Create background frame: + convert -size ${size} xc:none ${dest}/background.png -# Will start at frame 2 at first loop iteration -f=1 + # Remove first line (Layer 558): + ${SED} -i -e '1d' ${layers} -files="" + # Will start at frame 2 at first loop iteration + f=1 -while read l; do - f=$((${f} + 1)) + files="" - label=$(get_label "${l}") - p=$(get_pos "${l}") - nf=$(get_frame_id "${l}") + while read l; do + f=$((${f} + 1)) - log_dbg "Couche ${f}" - log_dbg " nom: ${label}" - log_dbg " pos: ${p}" + label=$(get_label "${l}") + p=$(get_pos "${l}") + nf=$(get_frame_id "${l}") - if is_skip_label "${label}"; then - log_dbg " skip..." - continue - fi + log_dbg "Couche ${f}" + log_dbg " nom: ${label}" + log_dbg " pos: ${p}" - files="${files} -page ${p} ${src}[${f}]" + if is_skip_label "${label}"; then + log_dbg " skip..." + continue + fi - if [ x"${nf}" != x"" ]; then - log_dbg "New frame ID: ${nf}" - convert -colorspace sRGB -page +0+0 ${dest}/background.png ${files} -background none -layers merge ${dest}/f${nf}.png - files="" - fi + files="${files} -page ${p} ${src}[${f}]" -done <${layers} + if [ x"${nf}" != x"" ]; then + log_dbg "New frame ID: ${nf}" + convert -colorspace sRGB -page +0+0 ${dest}/background.png ${files} -background none -layers merge ${dest}/f${nf}.png + files="" + fi + done <${layers} +fi if which ffmpeg 1> /dev/null 2>&1; then # Conversion vidéo: -- 2.20.1