mirror of
https://github.com/JanJastrow/ViThumbs.git
synced 2024-11-23 15:49:55 +01:00
Changed 120 to non-system variable
This commit is contained in:
parent
6f4ad038a7
commit
374e1b1fa2
42
vithumbs.sh
42
vithumbs.sh
@ -1,15 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "usage: ./vithumbs.sh INPUT [COLUMNS=5] [ROWS=5] [SIZE=1600]"
|
echo "usage: ./vithumbs.sh INPUT [COLS=5] [ROWS=5] [SIZE=1600]"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Define variables
|
# Define variables
|
||||||
INPUT=$1
|
INPUT=$1
|
||||||
COLUMNS=$2
|
COLS=$2
|
||||||
if [ -z "$COLUMNS" ]; then
|
if [ -z "$COLS" ]; then
|
||||||
COLUMNS=5
|
COLS=5
|
||||||
fi
|
fi
|
||||||
ROWS=$3
|
ROWS=$3
|
||||||
if [ -z "$ROWS" ]; then
|
if [ -z "$ROWS" ]; then
|
||||||
@ -19,7 +19,7 @@ SIZE=$4
|
|||||||
if [ -z "$SIZE" ]; then
|
if [ -z "$SIZE" ]; then
|
||||||
SIZE=1600
|
SIZE=1600
|
||||||
fi
|
fi
|
||||||
NFRAMES=$(echo "scale=0;$COLUMNS*$ROWS" | bc)
|
NFRAMES=$(echo "scale=0;$COLS*$ROWS" | bc)
|
||||||
DURX=$(ffmpeg -i "$INPUT" 2>&1 | grep Duration | awk '{print $2}' | tr -d ,)
|
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")
|
||||||
@ -30,27 +30,27 @@ TMPDIR="/tmp/thumbnails-${RANDOM}/"
|
|||||||
mkdir $TMPDIR
|
mkdir $TMPDIR
|
||||||
|
|
||||||
for (( VARIABLE=0; VARIABLE<NFRAMES; VARIABLE++ ))
|
for (( VARIABLE=0; VARIABLE<NFRAMES; VARIABLE++ ))
|
||||||
do
|
do
|
||||||
OFFSET=$(echo "scale=2;$VARIABLE*$DURATION/$NFRAMES+$DURATION/$NFRAMES/2" | bc)
|
OFFSET=$(echo "scale=2;$VARIABLE*$DURATION/$NFRAMES+$DURATION/$NFRAMES/2" | bc)
|
||||||
|
|
||||||
if [ $VARIABLE -gt 9 ];then
|
if [ $VARIABLE -gt 9 ];then
|
||||||
ZEROS="00"
|
ZEROS="00"
|
||||||
if [ $VARIABLE -gt 99 ];then
|
if [ $VARIABLE -gt 99 ];then
|
||||||
ZEROS="0"
|
ZEROS="0"
|
||||||
if [ $VARIABLE -gt 999 ];then
|
if [ $VARIABLE -gt 999 ];then
|
||||||
ZEROS=""
|
ZEROS=""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
ZEROS="000"
|
ZEROS="000"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create thumbnails
|
# Create thumbnails
|
||||||
ffmpeg -start_at_zero -copyts -ss $OFFSET -i "$INPUT" -vf "drawtext=fontfile=$FONT:fontsize=45:fontcolor=white::shadowcolor=black:shadowx=2:shadowy=2:box=1:boxcolor=black@0:x=(W-tw)/40:y=H-th-20:text='%{pts\:gmtime\:0\:%H\\\\\\:%M\\\\\:%S}'" -vframes 1 ${TMPDIR}$ZEROS$VARIABLE.png
|
ffmpeg -start_at_zero -copyts -ss $OFFSET -i "$INPUT" -vf "drawtext=fontfile=$FONT:fontsize=45:fontcolor=white::shadowcolor=black:shadowx=2:shadowy=2:box=1:boxcolor=black@0:x=(W-tw)/40:y=H-th-20:text='%{pts\:gmtime\:0\:%H\\\\\\:%M\\\\\:%S}'" -vframes 1 ${TMPDIR}$ZEROS$VARIABLE.png
|
||||||
done
|
done
|
||||||
|
|
||||||
# Merge thumbnails into tile image
|
# Merge thumbnails into tile image
|
||||||
ffmpeg -pattern_type glob -i "${TMPDIR}*.png" -filter_complex tile=${COLUMNS}x${COLUMNS}:margin=4:padding=4:color=white ${TMPDIR}output.png
|
ffmpeg -pattern_type glob -i "${TMPDIR}*.png" -filter_complex tile=${COLS}x${ROWS}:margin=4:padding=4:color=white ${TMPDIR}output.png
|
||||||
|
|
||||||
# Output metadata to file
|
# Output metadata to file
|
||||||
echo "Filename: $INPUT" >>${TMPDIR}metadata.txt
|
echo "Filename: $INPUT" >>${TMPDIR}metadata.txt
|
||||||
|
Loading…
Reference in New Issue
Block a user