2024-11-06 18:17:02 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SOURCEDIR=`pwd`
|
2024-11-06 19:15:43 +01:00
|
|
|
PROJECT=$1
|
|
|
|
BASETEMPLATE="nluug-title-template.svg"
|
|
|
|
SOURCEFILE="event.svg"
|
|
|
|
VIDEODIR=${SOURCEDIR}/output
|
|
|
|
PROJDIR=/tmp/nluug-intro-${PROJECT}
|
2024-11-06 18:17:02 +01:00
|
|
|
|
2024-11-06 19:15:43 +01:00
|
|
|
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"
|
2024-11-06 18:17:02 +01:00
|
|
|
# MAXLENGTH="SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER"
|
2024-11-06 19:15:43 +01:00
|
|
|
#SPEAKERNAME="Example Speaker Name"
|
2024-11-06 18:17:02 +01:00
|
|
|
# MAX="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
2024-11-06 19:15:43 +01:00
|
|
|
#TITLE1="Keynote: Some example title"
|
|
|
|
#TITLE2="With 3 lines, or use some whitespace"
|
|
|
|
#TITLE3="If less are needed"
|
2024-11-06 18:17:02 +01:00
|
|
|
|
|
|
|
CONV="convert -background black -fill black -alpha off"
|
|
|
|
FRAMENUM=0
|
|
|
|
|
|
|
|
# Make project directory
|
2024-11-06 19:15:43 +01:00
|
|
|
mkdir -p ${PROJDIR}; cd ${PROJDIR}
|
|
|
|
|
|
|
|
# Customize tempalte to this event from base template
|
|
|
|
cat ${SOURCEDIR}/$BASETEMPLATE | sed -e "s/EVENTNAMEEVENTNAMEEVENTNAMEEVENTNAME/$EVENTNAME/" > ${SOURCEFILE}
|
2024-11-06 18:17:02 +01:00
|
|
|
|
|
|
|
# Create initial image without title/speaker info
|
2024-11-06 19:15:43 +01:00
|
|
|
cat ${SOURCEFILE} | sed -e 's/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER//' -e 's/TITLE[123]//' > frameclear.svg
|
2024-11-06 18:17:02 +01:00
|
|
|
|
|
|
|
# Fade this image in from 100% transparant to 'normal'
|
|
|
|
echo "Generate fade-in-from-black sequence"
|
|
|
|
for i in `seq 100 -3 0`
|
|
|
|
do
|
|
|
|
echo "Generate frame ${FRAMENUM}"
|
|
|
|
${CONV} -colorize ${i}% frameclear.svg frame-${FRAMENUM}.webp
|
|
|
|
((FRAMENUM++))
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Add speakername sequence"
|
|
|
|
SLEN=${#SPEAKERNAME} # Length of name
|
|
|
|
# Copy a new frame, and fill in the speaker name 1 character at a time
|
|
|
|
for i in `seq 0 ${SLEN}`
|
|
|
|
do
|
|
|
|
echo "Generate frame ${FRAMENUM}"
|
|
|
|
SN="${SPEAKERNAME::$i}"
|
2024-11-06 19:15:43 +01:00
|
|
|
cat ${SOURCEFILE} | sed -e "s/TITLE[123]//" -e "s/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER/$SN/" > ${PROJDIR}/frame-${FRAMENUM}.svg
|
2024-11-06 18:17:02 +01:00
|
|
|
${CONV} frame-${FRAMENUM}.svg frame-${FRAMENUM}.webp
|
|
|
|
((FRAMENUM++))
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Add title sequence"
|
|
|
|
# With speakername, not add the title, 1 char (per line) at a time
|
|
|
|
for i in `seq 0 40`
|
|
|
|
do
|
|
|
|
echo "Generate frame ${FRAMENUM}"
|
|
|
|
T1="${TITLE1::$i}" # Substring, first i characters
|
|
|
|
T2="${TITLE2::$i}"
|
|
|
|
T3="${TITLE3::$i}"
|
2024-11-06 19:15:43 +01:00
|
|
|
cat ${SOURCEFILE} | sed -e "s/TITLE1/$T1/" -e "s/TITLE2/$T2/" -e "s/TITLE3/$T3/" -e "s/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER/$SN/" > ${PROJDIR}/frame-${FRAMENUM}.svg
|
2024-11-06 18:17:02 +01:00
|
|
|
${CONV} frame-${FRAMENUM}.svg frame-${FRAMENUM}.webp
|
|
|
|
((FRAMENUM++))
|
|
|
|
done
|
|
|
|
|
|
|
|
# Generate final frame, with full speakername + title
|
|
|
|
echo "Generate completed title"
|
2024-11-06 19:15:43 +01:00
|
|
|
cat ${SOURCEFILE} | sed -e "s/TITLE1/$TITLE1/" -e "s/TITLE2/$TITLE2/" -e "s/TITLE3/$TITLE3/" -e "s/SPEAKERSPEAKERSPEAKERSPEAKERSPEAKER/$SPEAKERNAME/" > ${PROJDIR}/frame-${FRAMENUM}.svg
|
2024-11-06 18:17:02 +01:00
|
|
|
${CONV} frame-${FRAMENUM}.svg frame-${FRAMENUM}.webp
|
|
|
|
LASTFRAME=$FRAMENUM
|
|
|
|
((FRAMENUM++))
|
|
|
|
|
|
|
|
# Now copy the rendered output of the last frame a few more times so we can read it before the video ends
|
|
|
|
for i in `seq 0 1 100`
|
|
|
|
do
|
|
|
|
echo "Duplicating frame ${FRAMENUM}"
|
|
|
|
cp frame-${LASTFRAME}.webp frame-${FRAMENUM}.webp
|
|
|
|
((FRAMENUM++))
|
|
|
|
done
|
|
|
|
|
|
|
|
# Fade this image out over 100 frames back to the normal view
|
|
|
|
echo "Generate fade-out-sequence"
|
|
|
|
for i in `seq 0 3 100`
|
|
|
|
do
|
|
|
|
echo "Generate frame ${FRAMENUM}"
|
|
|
|
${CONV} -colorize ${i}% frame-${LASTFRAME}.svg frame-${FRAMENUM}.webp
|
|
|
|
((FRAMENUM++))
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Rendering to video"
|
2024-11-06 19:15:43 +01:00
|
|
|
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
|