À̹ø¿¡´Â JAVA¸¦ ÀÌ¿ëÇÏ¿© mp3 ÆÄÀÏÀÇ Á¤º¸¸¦ ÀÐ¾î µéÀÌ´Â ¹æ¹ý¿¡ ´ëÇØ ¾Ë¾Æ º¸µµ·Ï ÇÏ°Ú½À´Ï´Ù
´ÙÇàÈ÷ mp3 ÆÄÀÏÀº Çì´õ ºÎºÐ¿¡ À¯¿ëÇÑ Á¤º¸¸¦ °®°í Àֱ⠶§¹®¿¡ FileSystemOject¸¦
ÀÌ¿ëÇÏ¿© ÇÊ¿äÇÑ Á¤º¸µéÀ» ¾ò¾î¿Ã ¼ö ÀÖ½À´Ï´Ù.
ÀÌ°ÍÀº ¿¹Àü¿¡ JMF¸¦ ÀÌ¿ëÇÏ¿© À¥°ú ¾ÖÇø®ÄÉÀÌ¼Ç ÆÄÀÏ°øÀ¯¸¦ À§ÇÑ ÇÁ·Î±×·¥À» ÀÛ¼ºÇÏ´Â
¼ö°»ýºÐ²²¼ ¿äûÇϽŠÀڷḦ www.id3.orgÀÇ ¸ÖƼ¹Ìµð¾îÆÄÀÏÇì´õ ³»¿ëÀ» Á¶»çÇÏ¿©
byte´ÜÀ§·Î üũÇÏ¿© º¸¿©ÁÖ´Â ÇÁ·Î±×·¥À» ÀÛ¼ºÇß½À´Ï´Ù.
°³¿ä¸¦ º¸ÀÚ¸é ¿ì¸®°¡ »ç¿ëÇÏ´Â ¸ðµç ÆÄÀÏ, ÇÁ·ÎÅäÄݵéÀº °¢ÀÚ¸¦ ÀνÄÇÒ¼ö ÀÖ°Ô²û
²¿¸®Ç¥¸¦ ´Þ¾Æ³õ°Ô µË´Ï´Ù. ¸»±×´ë·Î ¿©·¯ºÐµé ¾à±¹¿¡ °¡¼ ¾àÀ» »ç·Á±¸ Çϴµ¥ ¾à¿¡
»óÇ¥µéÀÌ ºÙ¾îÀÖÁö ¾Ê°Ô µÇ¸é ¾à»ç´Â Á¦´ë·Î µÈ ¾àÀ» ÁÙ¼ö ÀÖÀ»±î¿ä?
´ç¿¬È÷ ¾ø°ÚÁÒ? ¿ì¸®°¡ »ç¿ëÇÏ´Â ¸ðµç ÄÄÇ»ÅÍÀÇ ÀÚ·áµéÀÌ ±×·¸°Ô »ý°å´Ù ÀÌ°Ì´Ï´Ù.
Àü»êÀ» Àü°øÇϽŠºÐµéÀÌ¾ß ´ç¿¬È÷ ¾Æ½ÇÅ×±¸, »ç½Ç ¸ð¸£¼Åµµ µÇÁÒ. ÇÏÁö¸¸ ¸ð¸£´Â°Ô
¾àÀ̱⠺¸´Ù´Â ¾Æ´Â °ÍÀÌ ÈûÀ̹ǷΠ¾Æ¼Å¾ß ÇÕ´Ï´Ù.
º¸Åë ÆÄÀÏÀ̳ª ³×Æ®¿÷Àü¼ÛÁ¤º¸°°Àº °ÍµéÀº ¼ö½ÅÇÏ´Â ÃøÀ̳ª ÀÌ¿ëÇÏ´Â Ãø¿¡¼ ±×¿¡ ´ëÇÑ
Á¤º¸¸¦ ¾Ë¾Æ¾ß Çϱ⶧¹®¿¡ Çì´õ¶ó´Â °÷À» ¸ÕÀú ÀÛ¼ºÇÏ¿© ±×°Í¿¡ ´ëÇÑ ³»¿ëµéÀ» ´ã°í ÀÖ°Ô µË´Ï´Ù.
¿©±â¼´Â MP3ÆÄÀÏÀ» ¿¹·Î µé¾úÁö¸¸ AVI, MPEGµîµîÀÇ ÆÄÀ϶ÇÇÑ ÀÌ·± ±¸Á¶¸¦ °¡Áö°í ÀÖ½À´Ï´Ù.
ÀÚ ±×·¯¸é ±× ÆÄÀÏÁ¤º¸¿¡ ¹¹°¡ µé¾îÀÖ´ÂÁö Çѹø º¸µµ·Ï ÇÑ ÈÄ ÇÁ·Î±×·¥À» º¸µµ·Ï ÇսôÙ.
ID3/file identifier "ID3"
ID3 version $02 00
ID3 flags %xx000000
ID3 size 4 * %0xxxxxxx
À§¿Í °°Àº ³»¿ëÀ¸·Î ½ÃÀÛÇؼ song name, artist info, album name µîµîÀ» ¾Ë¾Æ³¾¼ö°¡ ÀÖ½À´Ï´Ù.
ÀÚ¼¼ÇÑ ³»¿ëÀº ¾Æ·¡ ÇÁ·Î±×·¥À» º¸½Ãµµ·Ï ÇÏÁÒ
½ÇÁ¦ MP3ÆÄÀÏÀ» Àоîµé¿©¼¿ä ±× Á¤º¸¸¦ result.txt·Î ÀúÀåÇÏ´Â ºÎºÐÀÔ´Ï´Ù.
ÆÄÀÏ¿¡ ´ëÇÑ Á¤º¸´Â ÃÖÁ¾ 128byte¿¡ ´ã°ÜÀÖ°Ô µË´Ï´Ù.
±× ºÎºÐÀ» °¢°¢¿¡ ´ëÇÑ Á¤º¸¸¦ ÀÌ¿ëÇÏ¿© parseParam()À̶ó´Â ¸Þ¼Òµå¸¦ ÀÌ¿ëÇÏ¿© ÆĽÌÇÏ°Ô µË´Ï´Ù.
ÀÚ ÀÌÁ¦ °á°úÀÔ´Ï´Ù.
source : HeaderTest.java
import java.io.*;
public class HeaderTest
{
public HeaderTest() {}
public void go() throws Exception
{
File f = new File("e:\\mp3\\pop\\shape.mp3");
FileInputStream fis = new FileInputStream(f);
FileOutputStream fos = new FileOutputStream("result.txt");
System.out.println("FileSize : " + f.length());
//ÃÖÁ¾ 128byte skip
fis.skip(f.length() - 128);
int ch = 0;
int count =0;
byte [] b = new byte[128];
while((ch = fis.read(b, 0, b.length)) != -1) {
fos.write(b, 0, ch);
}
String tag = parseParam(b, 0, 3);
String songName = parseParam(b, 3, 30);
String artist = parseParam(b, 33, 30);
String album = parseParam(b, 63, 30);
String year = parseParam(b, 93, 4);
String comment = parseParam(b, 97, 30);
String genre = parseParam(b, 127, 1);
System.out.println("Tag : " + tag);
System.out.println("Song Name : " + songName);
System.out.println("Artist : " + artist);
System.out.println("Album : " + album);
System.out.println("Year : " + year);
System.out.println("Comment : " + comment);
System.out.println("Genre : " + genre);
}
public String parseParam(byte [] src, int start, int offset) {
String paramValue = "";
int end = start + offset;
for( int i = start ; i < end ; i++ ) {
paramValue += (char)src[i];
}
return paramValue;
}
public static void main(String[] args) throws Exception
{
HeaderTest ht = new HeaderTest();
ht.go();
}
}
À§¿Í °°Àº ³»¿ëÁ¤º¸¸¦ ÀÐ¾î¼ ÆĽÌÇÏ´Â ÇÁ·Î±×·¥À» ÀÛ¼ºÇÏ°Ô µÇ¸é¿ä,
³ªÁß¿¡ ´Ù¸¥ ¹Ìµð¾îÆÄÀÏÀ̳ª ³×Æ®¿÷Àü¼ÛÁ¤º¸¸¦ ÀÚÀ¯ÀÚÀç·Î Çڵ鸵 ÇϽǼö ÀÖ½À´Ï´Ù.
¶ÇÇÑ ±×·¯ÇÑ °ÍµéÀÌ °æÇèÀ¸·Î Á¡Á¡ ½×ÀÎ´Ù¸é ¿©·¯ºÐµéÀÌ Á÷Á¢ ÀڽŸ¸ÀÇ ÇÁ·ÎÅäÄÝÀ» Á¤ÀÇÇÏ¿©
¿©·¯ºÐµéÀÇ ¾ÖÇø®ÄÉÀ̼ǿ¡ Àû¿ë½Ãų¼ö ÀÖ´Â ¼öÁØÀÌ À̸¦°Ì´Ï´Ù.
|