Move infobox design to variables

This commit is contained in:
Jan Jastrow 2022-01-20 00:05:21 +01:00
parent 5762679582
commit 7c647c493f

View File

@ -5,7 +5,7 @@ if [ -z "$1" ]; then
exit
fi
# Define variables
# Input variables
INPUT=$1
COLS=$2
if [ -z "$COLS" ]; then
@ -19,7 +19,16 @@ SIZE=$4
if [ -z "$SIZE" ]; then
SIZE=1600
fi
# Design variables
INFO_TEXTCOLOR="0xEEEEEE"
INFO_BGCOLOR="0x282828"
INFO_FONTSIZE=20
INFO_LINESPACING=5
INFO_HEIGHT=110
FONTFILE=""
# Render text in system monospace font if no other is defined
if [ -z "$FONTFILE" ]; then
FONT="font=Mono"
else
@ -32,8 +41,8 @@ DURX=$(ffmpeg -i "$INPUT" 2>&1 | grep Duration | awk '{print $2}' | tr -d ,)
DURATION=$(ffmpeg -i "$INPUT" 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,// | sed 's@\..*@@g' | awk '{ split($1, A, ":"); split(A[3], B, "."); print 3600*A[1] + 60*A[2] + B[1] }')
RES=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "$INPUT")
FILESIZE=$(du -sm "$INPUT" | awk '{print $1}')
METADATA_PX=110
TMPDIR="/tmp/thumbnails-${RANDOM}/"
mkdir $TMPDIR
for (( VARIABLE=0; VARIABLE<NFRAMES; VARIABLE++ ))
@ -64,11 +73,11 @@ scaledheight=$(echo "scale=0;$theheight*$SIZE/$thewidth" | bc)
ffmpeg $FFMPEG_VERBOSITY -i ${TMPDIR}tiled.png -vf scale=${SIZE}x${scaledheight} -vframes 1 ${TMPDIR}tiled_resized.png
# Add space to the top of the image
finalheight=$(echo "$scaledheight+$METADATA_PX" | bc)
finalheight=$(echo "$scaledheight+$INFO_HEIGHT" | bc)
# Add Metadata
ffmpeg -f lavfi -i color=0x282828:${SIZE}x${finalheight} $FFMPEG_VERBOSITY -i ${TMPDIR}tiled_resized.png \
-filter_complex "[0:v][1:v] overlay=0:$METADATA_PX,drawtext=$FONT:fontsize=20:fontcolor=0xEEEEEE:line_spacing=5:x=12:y=12:textfile=${TMPDIR}metadata.txt" \
ffmpeg -f lavfi -i color=$INFO_BGCOLOR:${SIZE}x${finalheight} $FFMPEG_VERBOSITY -i ${TMPDIR}tiled_resized.png \
-filter_complex "[0:v][1:v] overlay=0:$INFO_HEIGHT,drawtext=$FONT:fontsize=$INFO_FONTSIZE:fontcolor=$INFO_TEXTCOLOR:line_spacing=$INFO_LINESPACING:x=12:y=12:textfile=${TMPDIR}metadata.txt" \
-vframes 1 -q:v 2 "${INPUT}_vithumbs.jpg"
# Clean tempfiles