ID3 v1 tag

通常加在mp3檔案的最尾端, 總長度為128 bytes, 結構可以細分成以下幾個部分:
(1) identifier (3 bytes): "TAG"
(2) Song Title (30 bytes): 歌曲名稱
(3) Artist (30 bytes): 演唱者
(4) Album (30 bytes): 專輯名稱
(5) Year (4 bytes): 年份
(6)Comment (30 bytes): 備註
(7) Genre (1 byte): 曲風 ; 用0~79來表示
我們只要分析mp3檔案尾端最後128bytes, 驗證該起始點是否帶有3 bytes大小的identifier "TAG", 就可以知道這個檔案是否帶有 ID3v1 tag. 確認TAG之後,可依照 ID3v1 的固定格式,建立結構體,再依序存取個別欄位輸出資料.
| #include <stdio.h>
struct ID3v1{ char identifier[3]; char title [30]; char artist[30]; char album[30]; int year[4]; char comment[30]; int genre[1]; } arr;
int main (void){ FILE *fp; fp=fopen("XX.mp3","r"); fseek(fp,128,SEEK_END); fread(&arr ,sizeof(Struct ID3v1),fp); printf(........................ . . . . fclose(fp); } |
參考資料:
請先 登入 以發表留言。