-
Notifications
You must be signed in to change notification settings - Fork 40
FLAC Metadata
The introduction of FLAC is here present on Wikipedia.
Here is the structure of FLAC's metadata, the original format structure of FLAC is here present on SourceForge.net (You may need a proxy if you are in China mainland). :
Size Name Description
32 File Header Four fixed bytes: 0x66 0x4C 0x61 0x43 (fLaC)
Metadata Block
Header
1 Last flag 1: Last Block, 0: Not last block.
7 Block type 0: STREAMINFO
1: PADDING
2: APPLICATION
3: SEEKTABLE
4: VORBIS_COMMENT
5: CUESHEET
6: PICTURE
7-126 : Reserved
127: Invalid
24 Length The length of metadata, exclude the header.
?? Data The data of metadata.
The type 4(Vorbis Comment), 5(Cue Sheet), and 6(Picture) is important for us to get the tag information of the FLAC media.
Here is a sample of Vorbis Commit metadata block's data:
Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F
00000020 0B 00
00000030 00 00 4C 61 76 66 35 33 2E 32 34 2E 30 07 00 00 Lavf53.24.0
00000040 00 73 00 00 00 41 52 54 49 53 54 3D 42 69 42 69 s ARTIST=BiBi
00000050 EF BD 9E E7 B5 A2 E7 80 AC E7 B5 B5 E9 87 8C 28 锝炵耽鐎档閲?
00000060 43 56 2E E5 8D 97 E6 A2 9D E6 84 9B E4 B9 83 29 CV.?楁?鎰涗箖)
00000070 E3 80 81 E8 A5 BF E6 9C A8 E9 87 8E E7 9C 9F E5 銆 瑗挎湪閲庣湡?
00000080 A7 AB 28 43 56 2E 50 69 6C 65 29 E3 80 81 E7 9F Й(CV.Pile)銆 鐭
00000090 A2 E6 BE A4 E3 81 AB E3 81 93 28 43 56 2E E5 BE ㈡兢? ?CV.寰
000000A0 B3 E4 BA 95 E9 9D 92 E7 A9 BA 29 20 66 72 6F 6D 充簳?掔┖) from
000000B0 20 CE BC 27 73 EF BD 9E 13 00 00 00 54 49 54 4C 渭's锝? TITL
000000C0 45 3D 43 75 74 69 65 20 50 61 6E 74 68 65 72 0D E=Cutie Panther
000000D0 00 00 00 54 4F 54 41 4C 54 52 41 43 4B 53 3D 35 TOTALTRACKS=5
000000E0 60 00 00 00 41 6C 62 75 6D 3D 54 56 E3 82 A2 E3 ` Album=TV銈
000000F0 83 8B E3 83 A1 E3 80 8C E3 83 A9 E3 83 96 E3 83 儖銉°€屻儵銉栥?
00000100 A9 E3 82 A4 E3 83 96 EF BC 81 E3 80 8D E3 83 A6 ┿偆銉栵?銆 銉?
00000110 E3 83 8B E3 83 83 E3 83 88 E3 82 B7 E3 83 B3 E3 銉嬨儍銉堛偡銉炽
00000120 82 B0 E3 83 AB 20 32 6E 64 20 73 65 73 73 69 6F 偘銉?2nd sessio
00000130 6E E3 80 8C 43 75 74 69 65 20 50 61 6E 74 68 65 n銆孋utie Panthe
00000140 72 E3 80 8D 0B 00 00 00 47 65 6E 72 65 3D 41 6E r銆 Genre=An
00000150 69 6D 65 09 00 00 00 44 41 54 45 3D 32 30 31 33 ime DATE=2013
00000160 0D 00 00 00 54 52 41 43 4B 4E 55 4D 42 45 52 3D TRACKNUMBER=
00000170 31 1
There's a string like 'Lavf53.24.0' at the begin, should jump over. It's a 4-byte length+string data+4-byte unknown data.
Then all the data is in the following structure, it's a Pascal-style string:
4-bytes length + text data in UTF-8
The structure of picture frame is simple:
Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F
00000170 06 02 D9 25 00 00 00 03 00 00 00 0A 69 6D 61 ? ima
00000180 67 65 2F 6A 70 65 67 00 00 00 00 00 00 01 F4 00 ge/jpeg ?
00000190 00 01 F4 00 00 00 18 00 00 00 00 00 02 D8 FB FF ? 佧
000001A0 D8 FF E0 00 10 4A 46 49 46 (Binary Data) ?? JFIF
Picture metadata block start with 4-bytes type. In the sample is 00 00 00 03(0x00000175~0x00000178).
Here is a list of the image type index, it's the same as ID3v2:
0 - Other
1 - 32x32 pixels 'file icon' (PNG only)
2 - Other file icon
3 - Cover (front)
4 - Cover (back)
5 - Leaflet page
6 - Media (e.g. label side of CD)
7 - Lead artist/lead performer/soloist
8 - Artist/performer
9 - Conductor
10 - Band/Orchestra
11 - Composer
12 - Lyricist/text writer
13 - Recording Location
14 - During recording
15 - During performance
16 - Movie/video screen capture
17 - A bright coloured fish
18 - Illustration
19 - Band/artist logotype
20 - Publisher/Studio logotype
Following a 4-bytes length mime type discription string size. In the example, the MIME-Type is 'image/jpeg'.
Then is a 4-bytes length description size. In the sample it's empty, so it's 0.
Then follows these 4-bytes data: width, height, depth, index color num.
After that, it's 4-bytes image data size and image binary data.
© 2013-2017 Kreogist Dev Team.
All other trademarks are the property of their respective owners. Hosted on GitHub. Powered by MarkDown.