From 2273e169082b38f2afb50d8e3ad0b028650e8b72 Mon Sep 17 00:00:00 2001 From: Mark Janssen Date: Wed, 6 Nov 2024 19:15:43 +0100 Subject: [PATCH] Take input from env-vars, render to output directory --- .gitignore | 1 + generate.sh | 53 ++++++++++++++++++++++++++++++---------- nluug-title-template.svg | 2 +- 3 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53752db --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +output diff --git a/generate.sh b/generate.sh index 1560817..3d84673 100755 --- a/generate.sh +++ b/generate.sh @@ -1,24 +1,49 @@ #!/bin/bash SOURCEDIR=`pwd` -SOURCEFILE="nluug-title-template.svg" -PROJDIR=`pwd`/proj1/ +PROJECT=$1 +BASETEMPLATE="nluug-title-template.svg" +SOURCEFILE="event.svg" +VIDEODIR=${SOURCEDIR}/output +PROJDIR=/tmp/nluug-intro-${PROJECT} +if [ -z "${PROJECT}" ]; then + echo "Usage: $0 " + exit 1; +fi + +if [ -z "$EVENTNAME" ]; then + echo "Specify EVENTNAME env-var" + exit 2; +fi +if [ -z "$SPEAKERNAME" ]; then + echo "Specify SPEAKERNAME env-var" + exit 3; +fi +if [ -z "$TITLE1" -o -z "$TITLE2" -o -z "$TITLE3" ]; then + echo "Specify TITLE1/TITLE2/TITLE3 env-vars" + exit 4; +fi + +# EVENTNAME="NLUUG Najaar 5 November 2024" # MAXLENGTH="SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER" -SPEAKERNAME="Gunes Acar" +#SPEAKERNAME="Example Speaker Name" # MAX="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -TITLE1="Keynote: From Cookies to" -TITLE2="Keyloggers: Understanding Modern" -TITLE3="Online Tracking Techniques" +#TITLE1="Keynote: Some example title" +#TITLE2="With 3 lines, or use some whitespace" +#TITLE3="If less are needed" CONV="convert -background black -fill black -alpha off" FRAMENUM=0 # Make project directory -mkdir ${PROJDIR}; cd ${PROJDIR} +mkdir -p ${PROJDIR}; cd ${PROJDIR} + +# Customize tempalte to this event from base template +cat ${SOURCEDIR}/$BASETEMPLATE | sed -e "s/EVENTNAMEEVENTNAMEEVENTNAMEEVENTNAME/$EVENTNAME/" > ${SOURCEFILE} # Create initial image without title/speaker info -cat ${SOURCEDIR}/${SOURCEFILE} | sed -e 's/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER//' -e 's/TITLE[123]//' > ${PROJDIR}/frameclear.svg +cat ${SOURCEFILE} | sed -e 's/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER//' -e 's/TITLE[123]//' > frameclear.svg # Fade this image in from 100% transparant to 'normal' echo "Generate fade-in-from-black sequence" @@ -36,7 +61,7 @@ for i in `seq 0 ${SLEN}` do echo "Generate frame ${FRAMENUM}" SN="${SPEAKERNAME::$i}" - cat ${SOURCEDIR}/${SOURCEFILE} | sed -e "s/TITLE[123]//" -e "s/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER/$SN/" > ${PROJDIR}/frame-${FRAMENUM}.svg + cat ${SOURCEFILE} | sed -e "s/TITLE[123]//" -e "s/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER/$SN/" > ${PROJDIR}/frame-${FRAMENUM}.svg ${CONV} frame-${FRAMENUM}.svg frame-${FRAMENUM}.webp ((FRAMENUM++)) done @@ -62,14 +87,14 @@ do T1="${TITLE1::$i}" # Substring, first i characters T2="${TITLE2::$i}" T3="${TITLE3::$i}" - cat ${SOURCEDIR}/${SOURCEFILE} | sed -e "s/TITLE1/$T1/" -e "s/TITLE2/$T2/" -e "s/TITLE3/$T3/" -e "s/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER/$SN/" > ${PROJDIR}/frame-${FRAMENUM}.svg + cat ${SOURCEFILE} | sed -e "s/TITLE1/$T1/" -e "s/TITLE2/$T2/" -e "s/TITLE3/$T3/" -e "s/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER/$SN/" > ${PROJDIR}/frame-${FRAMENUM}.svg ${CONV} frame-${FRAMENUM}.svg frame-${FRAMENUM}.webp ((FRAMENUM++)) done # Generate final frame, with full speakername + title echo "Generate completed title" -cat ${SOURCEDIR}/${SOURCEFILE} | sed -e "s/TITLE1/$TITLE1/" -e "s/TITLE2/$TITLE2/" -e "s/TITLE3/$TITLE3/" -e "s/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER/$SPEAKERNAME/" > ${PROJDIR}/frame-${FRAMENUM}.svg +cat ${SOURCEFILE} | sed -e "s/TITLE1/$TITLE1/" -e "s/TITLE2/$TITLE2/" -e "s/TITLE3/$TITLE3/" -e "s/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER/$SPEAKERNAME/" > ${PROJDIR}/frame-${FRAMENUM}.svg ${CONV} frame-${FRAMENUM}.svg frame-${FRAMENUM}.webp LASTFRAME=$FRAMENUM ((FRAMENUM++)) @@ -92,5 +117,7 @@ do done echo "Rendering to video" -ffmpeg -framerate 30 -i frame-%d.webp -c:v libx264 -r 30 intro-x264.mkv -ffmpeg -framerate 30 -i frame-%d.webp -c:v vp9 -r 30 intro-vp9.webm +ffmpeg -framerate 30 -i frame-%d.webp -c:v libx264 -r 30 ${VIDEODIR}/${PROJECT}-x264.mkv +ffmpeg -framerate 30 -i frame-%d.webp -c:v vp9 -r 30 ${VIDEODIR}/${PROJECT}-vp9.webm + +rm *.svg frame-*.webp diff --git a/nluug-title-template.svg b/nluug-title-template.svg index a5ac126..89b2442 100644 --- a/nluug-title-template.svg +++ b/nluug-title-template.svg @@ -71,7 +71,7 @@ transform="matrix(0.64500845,0,0,0.64500845,576.16803,19.38728)">NLUUG Najaar 5 Nov 2024 + id="tspan196">EVENTNAMEEVENTNAMEEVENTNAMEEVENTNAME