Skip to content

Commit b6cc2e0

Browse files
committed
Add padding to last tile (if needed) in gen_tiles.sh
1 parent cd1072f commit b6cc2e0

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

media/TrickPlayThumbnailsDASH/run_scripts_dash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ DIR=test-$RESOLUTION
3434
PWD=`pwd`
3535
mkdir $DIR
3636
./scripts/gen_thumbs.sh $INFILE $DIR/ind $RESOLUTION $INTERVAL
37-
./scripts/gen_tiles.sh $DIR ind $OUTPREFIX $COLS $ROWS
37+
./scripts/gen_tiles.sh $DIR ind $OUTPREFIX $RESOLUTION $COLS $ROWS
3838
echo
3939
echo "Output for thumbnails: add the image adaptation set to master mpd file"
4040
./scripts/gen_manifest.sh $INFILE $OUTPREFIX $RESOLUTION $COLS $ROWS $INTERVAL

media/TrickPlayThumbnailsDASH/scripts/gen_tiles.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
# http://www.imagemagick.org/script/command-line-options.php#append
88
# https://github.com/image-media-playlist/spec/blob/master/image_media_playlist_v0_4.pdf
99
# https://www.tecmint.com/install-imagemagick-in-linux/
10+
# https://stackoverflow.com/questions/39504522/create-blank-image-in-imagemagick
11+
# https://stackoverflow.com/questions/5688576/how-to-use-mod-operator-in-bash
1012

11-
if [ $# -lt 5 ]; then
12-
echo "Usage: $0 <thumbnails-dir> <input-prefix> <output-prefix> <cols> <rows>"
13+
if [ $# -lt 6 ]; then
14+
echo "Usage: $0 <thumbnails-dir> <input-prefix> <output-prefix> <resolution> <cols> <rows>"
1315
exit 1
1416
fi
1517

1618
INDIR=$1
1719
INPREFIX=$2
1820
OUTPREFIX=$3
19-
COLS=$4
20-
ROWS=$5
21+
RESOLUTION=$4
22+
COLS=$5
23+
ROWS=$6
2124

2225
# All parameters need to be specified
2326
# The $INDIR parameter is a directory containing the thumbnails
@@ -50,8 +53,36 @@ if [ ${ROWS} -eq 1 ] && [ ${COLS} -eq 1 ]; then
5053
exit 0
5154
fi
5255

53-
# normal handling of tile generation
56+
# calculate thumbs need to fill N tiles, result is TILETHUMBS
57+
# and LASTTILE is the tile that may need to be padded
5458
let "TILESIZE=$COLS * $ROWS"
59+
let "TILETHUMBS=$TILESIZE"
60+
let "LASTTILE=1"
61+
while [ $TILETHUMBS -lt $THUMBCOUNT ]
62+
do
63+
let "TILETHUMBS=$TILETHUMBS + $TILESIZE"
64+
let "LASTTILE=$LASTTILE + 1"
65+
done
66+
67+
# generation of padding for the last tile, if padding is needed
68+
if [ $TILETHUMBS -gt $THUMBCOUNT ]; then
69+
let "ALIGNCOUNT=$TILETHUMBS - $THUMBCOUNT"
70+
echo "ALIGNCOUNT = $ALIGNCOUNT"
71+
COUNT=1
72+
mkdir tile${LASTTILE}
73+
while [ $COUNT -le $ALIGNCOUNT ]
74+
do
75+
let "TILENUM=$THUMBCOUNT + $COUNT"
76+
let "COUNT=$COUNT + 1"
77+
convert -size ${RESOLUTION} xc:black tile${LASTTILE}/$INPREFIX-${TILENUM}.jpg
78+
done
79+
80+
# finally, reset THUMBCOUNT to include padded tiles
81+
#let "THUMBCOUNT=$THUMBCOUNT + $ALIGNCOUNT"
82+
#echo "THUMBCOUNT = $THUMBCOUNT"
83+
fi
84+
85+
# normal handling of tile generation
5586
while [ $STARTTILE -lt $THUMBCOUNT ]
5687
do
5788
let "ENDTILE= $STARTTILE + $TILESIZE - 1"

0 commit comments

Comments
 (0)