blob: e4c52f783fa3a0ee7c47a50f03cda912506b401b [file] [log] [blame] [view]
Geoffrey Pitschdd214a72016-06-27 17:14:30 -04001# bootanimation format
2
3## zipfile paths
4
5The system selects a boot animation zipfile from the following locations, in order:
6
7 /system/media/bootanimation-encrypted.zip (if getprop("vold.decrypt") = '1')
8 /system/media/bootanimation.zip
9 /oem/media/bootanimation.zip
10
11## zipfile layout
12
13The `bootanimation.zip` archive file includes:
14
15 desc.txt - a text file
16 part0 \
17 part1 \ directories full of PNG frames
18 ... /
19 partN /
20
21## desc.txt format
22
23The first line defines the general parameters of the animation:
24
25 WIDTH HEIGHT FPS
26
27 * **WIDTH:** animation width (pixels)
28 * **HEIGHT:** animation height (pixels)
29 * **FPS:** frames per second, e.g. 60
30
31It is followed by a number of rows of the form:
32
33 TYPE COUNT PAUSE PATH [#RGBHEX CLOCK]
34
35 * **TYPE:** a single char indicating what type of animation segment this is:
36 + `p` -- this part will play unless interrupted by the end of the boot
37 + `c` -- this part will play to completion, no matter what
38 * **COUNT:** how many times to play the animation, or 0 to loop forever until boot is complete
39 * **PAUSE:** number of FRAMES to delay after this part ends
40 * **PATH:** directory in which to find the frames for this part (e.g. `part0`)
41 * **RGBHEX:** _(OPTIONAL)_ a background color, specified as `#RRGGBB`
42 * **CLOCK:** _(OPTIONAL)_ the y-coordinate at which to draw the current time (for watches)
43
44There is also a special TYPE, `$SYSTEM`, that loads `/system/media/bootanimation.zip`
45and plays that.
46
47## loading and playing frames
48
49Each part is scanned and loaded directly from the zip archive. Within a part directory, every file
50(except `trim.txt` and `audio.wav`; see next sections) is expected to be a PNG file that represents
51one frame in that part (at the specified resolution). For this reason it is important that frames be
52named sequentially (e.g. `part000.png`, `part001.png`, ...) and added to the zip archive in that
53order.
54
55## trim.txt
56
57To save on memory, textures may be trimmed by their background color. trim.txt sequentially lists
58the trim output for each frame in its directory, so the frames may be properly positioned.
59Output should be of the form: `WxH+X+Y`. Example:
60
61 713x165+388+914
62 708x152+388+912
63 707x139+388+911
64 649x92+388+910
65
66If the file is not present, each frame is assumed to be the same size as the animation.
67
68## audio.wav
69
70Each part may optionally play a `wav` sample when it starts. To enable this for an animation,
71you must also include a `audio_conf.txt` file in the ZIP archive. Its format is as follows:
72
73 card=<ALSA card number>
74 device=<ALSA device number>
75 period_size=<period size>
76 period_count=<period count>
77
78This header is followed by zero or more mixer settings, each with the format:
79
80 mixer "<name>" = <value list>
81
82Here's an example `audio_conf.txt` from Shamu:
83
84 card=0
85 device=15
86 period_size=1024
87 period_count=4
88
89 mixer "QUAT_MI2S_RX Audio Mixer MultiMedia5" = 1
90 mixer "Playback Channel Map" = 0 220 157 195 0 0 0 0
91 mixer "QUAT_MI2S_RX Channels" = Two
92 mixer "BOOST_STUB Right Mixer right" = 1
93 mixer "BOOST_STUB Left Mixer left" = 1
94 mixer "Compress Playback 9 Volume" = 80 80
95
96You will probably need to get these mixer names and values out of `audio_platform_info.xml`
97and `mixer_paths.xml` for your device.
98
99## exiting
100
101The system will end the boot animation (first completing any incomplete or even entirely unplayed
102parts that are of type `c`) when the system is finished booting. (This is accomplished by setting
103the system property `service.bootanim.exit` to a nonzero string.)
104
105## protips
106
107### PNG compression
108
109Use `zopflipng` if you have it, otherwise `pngcrush` will do. e.g.:
110
111 for fn in *.png ; do
112 zopflipng -m ${fn}s ${fn}s.new && mv -f ${fn}s.new ${fn}
113 # or: pngcrush -q ....
114 done
115
116Some animations benefit from being reduced to 256 colors:
117
118 pngquant --force --ext .png *.png
119 # alternatively: mogrify -colors 256 anim-tmp/*/*.png
120
121### creating the ZIP archive
122
123 cd <path-to-pieces>
124 zip -0qry -i \*.txt \*.png \*.wav @ ../bootanimation.zip *.txt part*
125
126Note that the ZIP archive is not actually compressed! The PNG files are already as compressed
127as they can reasonably get, and there is unlikely to be any redundancy between files.