-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_assets.sh
124 lines (113 loc) · 3.16 KB
/
process_assets.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# by default this only processes new files
# if you want to update an existing file, delete the output first
# instructions for how to use this are in the README
# best practices: https://github.com/nprapps/bestpractices/blob/master/assets.md
# set to "error" to suppress logs
ffmpeg_log="error"
# convert images
# requires ImageMagick 7
cd src/assets/synced/images
mkdir -p resized
for img in *.jpg; do
if [ ! -f resized/$img ]; then
echo "Processing $img..."
magick convert $img -resize 1600x1200\> -quality 75 -strip -sampling-factor 4:2:0 -define jpeg:dct-method=float -interlace Plane resized/$img;
fi
done
for img in *.png; do
if [ ! -f resized/$img ]; then
echo "Processing $img..."
magick convert $img -resize 1600x1200\> \
-define png:compression-filter=5 \
-define png:compression-level=9 \
resized/$img;
fi
done
for img in *.jpeg; do
if [ ! -f resized/$img ]; then
echo "Processing $img..."
magick convert $img -resize 1600x1200\> \
-define png:compression-filter=5 \
-define png:compression-level=9 \
resized/$img;
fi
done
# handle silenced video
cd ../video
mkdir -p resized
for video in *.mp4; do
# create the videos
if [ ! -f resized/$video ]; then
echo "Processing $video..."
ffmpeg -n -nostats -hide_banner -loglevel $ffmpeg_log \
-i $video \
-an \
-vcodec libx264 \
-preset veryslow \
-strict -2 \
-pix_fmt yuv420p \
-crf 25 \
-vf scale=1600:-2 \
-movflags +faststart \
resized/$video;
fi
if [ ! -f resized/mobile-$video ]; then
echo "Processing mobile version of $video..."
ffmpeg -n -nostats -hide_banner -loglevel $ffmpeg_log \
-i $video \
-an \
-vcodec libx264 \
-preset veryslow \
-strict -2 \
-pix_fmt yuv420p \
-crf 25 \
-vf scale=800:-2 \
-movflags +faststart \
resized/mobile-$video;
fi
# create posters
if [ ! -f resized/$video.jpg ]; then
echo "Processing poster image for $video..."
ffmpeg -n -nostats -hide_banner -loglevel $ffmpeg_log \
-i $video \
-vf scale=1600:-2 \
-qscale:v 4 \
-frames:v 1 \
resized/$video.jpg;
fi
done
# convert audio
cd ../audio
mkdir -p resized
for audio in *.mp3; do
# create the audio
if [ ! -f resized/$audio ]; then
echo "Processing $audio..."
lame -m s -b 96 $audio resized/$audio;
fi
done
# convert ai2html images
cd ../ai-img
mkdir -p resized
for img in *.jpg; do
if [ ! -f resized/$img ]; then
echo "Processing $img..."
magick convert $img -resize 1600x1600\> -quality 75 -strip -sampling-factor 4:2:0 -define jpeg:dct-method=float -interlace Plane resized/$img;
fi
done
# convert thumbnails
cd ../thumbnails
mkdir -p resized
for img in *.jpg; do
if [ ! -f resized/$img ]; then
echo "Processing $img..."
magick convert $img -resize 800x800\> -quality 70 -strip -sampling-factor 4:2:0 -define jpeg:dct-method=float -interlace Plane resized/$img;
fi
done
# for img in *.jpeg; do
# echo "Processing $img..."
# # if [ ! -f $img ]; then
# magick convert $img -resize 600x600\> -quality 75 -strip -sampling-factor 4:2:0 -define jpeg:dct-method=float -interlace Plane resized/$img;
# # fi
# done