Take input from env-vars, render to output directory

This commit is contained in:
Mark Janssen 2024-11-06 19:15:43 +01:00
parent d40748c66d
commit 2273e16908
No known key found for this signature in database
GPG key ID: D8674D8FC4F69BD2
3 changed files with 42 additions and 14 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
output

View file

@ -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 <project>"
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

View file

@ -71,7 +71,7 @@
transform="matrix(0.64500845,0,0,0.64500845,576.16803,19.38728)"><tspan
x="107.36523"
y="802.76728"
id="tspan196">NLUUG Najaar 5 Nov 2024</tspan></text>
id="tspan196">EVENTNAMEEVENTNAMEEVENTNAMEEVENTNAME</tspan></text>
<text
xml:space="preserve"
id="text281-5"

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB