mirror of
https://github.com/JanJastrow/ViThumbs.git
synced 2024-11-23 15:49:55 +01:00
Move infobox design to variables
This commit is contained in:
parent
5762679582
commit
7c647c493f
19
vithumbs.sh
19
vithumbs.sh
@ -5,7 +5,7 @@ if [ -z "$1" ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Define variables
|
# Input variables
|
||||||
INPUT=$1
|
INPUT=$1
|
||||||
COLS=$2
|
COLS=$2
|
||||||
if [ -z "$COLS" ]; then
|
if [ -z "$COLS" ]; then
|
||||||
@ -19,7 +19,16 @@ SIZE=$4
|
|||||||
if [ -z "$SIZE" ]; then
|
if [ -z "$SIZE" ]; then
|
||||||
SIZE=1600
|
SIZE=1600
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Design variables
|
||||||
|
INFO_TEXTCOLOR="0xEEEEEE"
|
||||||
|
INFO_BGCOLOR="0x282828"
|
||||||
|
INFO_FONTSIZE=20
|
||||||
|
INFO_LINESPACING=5
|
||||||
|
INFO_HEIGHT=110
|
||||||
FONTFILE=""
|
FONTFILE=""
|
||||||
|
|
||||||
|
# Render text in system monospace font if no other is defined
|
||||||
if [ -z "$FONTFILE" ]; then
|
if [ -z "$FONTFILE" ]; then
|
||||||
FONT="font=Mono"
|
FONT="font=Mono"
|
||||||
else
|
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] }')
|
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")
|
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}')
|
FILESIZE=$(du -sm "$INPUT" | awk '{print $1}')
|
||||||
METADATA_PX=110
|
|
||||||
TMPDIR="/tmp/thumbnails-${RANDOM}/"
|
TMPDIR="/tmp/thumbnails-${RANDOM}/"
|
||||||
|
|
||||||
mkdir $TMPDIR
|
mkdir $TMPDIR
|
||||||
|
|
||||||
for (( VARIABLE=0; VARIABLE<NFRAMES; VARIABLE++ ))
|
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
|
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
|
# Add space to the top of the image
|
||||||
finalheight=$(echo "$scaledheight+$METADATA_PX" | bc)
|
finalheight=$(echo "$scaledheight+$INFO_HEIGHT" | bc)
|
||||||
|
|
||||||
# Add Metadata
|
# Add Metadata
|
||||||
ffmpeg -f lavfi -i color=0x282828:${SIZE}x${finalheight} $FFMPEG_VERBOSITY -i ${TMPDIR}tiled_resized.png \
|
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:$METADATA_PX,drawtext=$FONT:fontsize=20:fontcolor=0xEEEEEE:line_spacing=5:x=12:y=12:textfile=${TMPDIR}metadata.txt" \
|
-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"
|
-vframes 1 -q:v 2 "${INPUT}_vithumbs.jpg"
|
||||||
|
|
||||||
# Clean tempfiles
|
# Clean tempfiles
|
||||||
|
Loading…
Reference in New Issue
Block a user