使用C#读写Mp3的Tag信息
The TAG is used to describe the MPEG Audio file. It contains information about artist, title, album, publishing year and genre. There is some extra space for comments. It is exactly 128 bytes long and is located at very end of the audio data. You can get it by reading the last 128 bytes of the MPEG audio file.
AAABBBBB BBBBBBBB BBBBBBBB BBBBBBBB
BCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCD
DDDDDDDD DDDDDDDD DDDDDDDD DDDDDEEE
EFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFG
Sign | Length (bytes) |
Position (bytes) |
Description |
A | 3 | (0-2) | Tag identification. Must contain 'TAG' if tag exists and is correct. |
B | 30 | (3-32) | Title |
C | 30 | (33-62) | Artist |
D | 30 | (63-92) | Album |
E | 4 | (93-96) | Year |
F | 30 | (97-126) | Comment |
G | 1 | (127) | Genre |
The specification asks for all fields to be padded with null character (ASCII 0). However, not all applications respect this (an example is WinAmp which pads fields with <space>, ASCII 32).
There is a small change proposed in MP3v1.1 structure. The last byte of the Comment field may be used to specify the track number of a song in an album. It should contain a null character (ASCII 0) if the information is unknown.
Genre is a numeric field which may have one of the following values:
0
|
'Blues'
|
20
|
'Alternative'
|
40
|
'AlternRock'
|
60
|
'Top 40'
|
1
|
'Classic Rock'
|
21
|
'Ska'
|
41
|
'Bass'
|
61
|
'Christian Rap'
|
2
|
'Country'
|
22
|
'Death Metal'
|
42
|
'Soul'
|
62
|
'Pop/Funk'
|
3
|
'Dance'
|
23
|
'Pranks'
|
43
|
'Punk'
|
63
|
'Jungle'
|
4
|
'Disco'
|
24
|
'Soundtrack'
|
44
|
'Space'
|
64
|
'Native American'
|
5
|
'Funk'
|
25
|
'Euro-Techno'
|
45
|
'Meditative'
|
65
|
'Cabaret'
|
6
|
'Grunge'
|
26
|
'Ambient'
|
46
|
'Instrumental Pop'
|
66
|
'New Wave'
|
7
|
'Hip-Hop'
|
27
|
'Trip-Hop'
|
47
|
'Instrumental Rock'
|
67
|
'Psychadelic'
|
8
|
'Jazz'
|
28
|
'Vocal'
|
48
|
'Ethnic'
|
68
|
'Rave'
|
9
|
'Metal'
|
29
|
'Jazz+Funk'
|
49
|
'Gothic'
|
69
|
'Showtunes'
|
10
|
'New Age'
|
30
|
'Fusion'
|
50
|
'Darkwave'
|
70
|
'Trailer'
|
11
|
'Oldies'
|
31
|
'Trance'
|
51
|
'Techno-Industrial'
|
71
|
'Lo-Fi'
|
12
|
'Other'
|
32
|
'Classical'
|
52
|
'Electronic'
|
72
|
'Tribal'
|
13
|
'Pop'
|
33
|
'Instrumental'
|
53
|
'Pop-Folk'
|
73
|
'Acid Punk'
|
14
|
'R&B'
|
34
|
'Acid'
|
54
|
'Eurodance'
|
74
|
'Acid Jazz'
|
15
|
'Rap'
|
35
|
'House'
|
55
|
'Dream'
|
75
|
'Polka'
|
16
|
'Reggae'
|
36
|
'Game'
|
56
|
'Southern Rock'
|
76
|
'Retro'
|
17
|
'Rock'
|
37
|
'Sound Clip'
|
57
|
'Comedy'
|
77
|
'Musical'
|
18
|
'Techno'
|
38
|
'Gospel'
|
58
|
'Cult'
|
78
|
'Rock & Roll'
|
19
|
'Industrial'
|
39
|
'Noise'
|
59
|
'Gangsta'
|
79
|
'Hard Rock'
|
Any other value should be considered as 'Unknown'
|