Showing posts with label id3. Show all posts
Showing posts with label id3. Show all posts

March 27, 2014

exiftool

കൂൾ റീഡറിനെ(http://coolreader.org/e-index.htm) കുറിച്ചെഴുതണോ അതോ എംപിഡിയെ (https://en.wikipedia.org/wiki/Music_Player_Daemon) കുറിച്ചെഴുതണോ എന്നു കൺഫ്യു ആയപ്പോൾ എക്സിഫ് ടൂളിനെ (exiftool)‌‌ ക്കുറിച്ചെഴുതാം എന്നു വിചാരിച്ചു.
എക്സിഫ്‌‌ടൂൾ എന്ന പേര് കുറച്ച് തെറ്റിദ്ധാരണാജനകമാണെന്നാണ് എന്റെ വിനീതാഭിപ്രായം. കാരണം മറ്റൊന്നുമല്ല, പേരു കേൾക്കുമ്പോൾ ഇമേജ് ഫയലുകളിലെ എക്സിഫ് ഡേറ്റാ എടുക്കാനുള്ള ഒരു ടൂളാണെന്നാണ് തോന്നും. ഒന്നു രണ്ടു പ്രാവശ്യം ഉപയോഗിച്ചു നോക്കിയപ്പോഴാണ് സംഭവം മിക്കവാറും എല്ലാ തരം മീഡിയ ഫയലുകളിൽ നിന്നും മെറ്റാഡേറ്റാ എടുക്കാൻ പറ്റിയ ഒരു സാധനമാണെന്നു മനസ്സിലായത്.
ഏതെങ്കിലും ക്യാമറയിൽ നിന്നുള്ള ഫോട്ടോ ഫയലിൽ എക്സിഫ് ടൂൾ ഓടിച്ചാൽ അതിലുള്ള ഒരു വിധം എല്ലാ മെറ്റാഡേറ്റയും അതു ലിസ്റ്റ് ചെയ്യും. ഉദാ :
exiftool  IMG_3924.CR2
ExifTool Version Number         : 9.46
File Name                       : IMG_3924.CR2
Directory                       : .
File Size                       : 8.7 MB
File Modification Date/Time     : 2011:09:29 21:17:53+05:30
File Access Date/Time           : 2014:03:27 19:13:21+05:30
File Inode Change Date/Time     : 2013:08:17 19:52:54+05:30
File Permissions                : rwxr--r--
File Type                       : CR2
MIME Type                       : image/x-canon-cr2

Light Value                     : 11.0
Red Balance                     : 2.027344
കാനണിൽ നിന്നുള്ള റോ ഫയലിൽ നിന്ന് 285 ടാഗുകൾ ലിസ്റ്റ് ചെയ്തു
ആദ്യമായി exiftool ഉപയോഗിച്ചത് ടാബ്‌‌ലറ്റിന്റെ മെമ്മറി കാർഡിലെ ഫയലുകൾ റിക്കവർ ചെയ്തപ്പോഴാണ്. റിക്കവർ ചെയ്ത ഫയലുകളുടെ പേരെല്ലാം ഒരു വഴിക്കായിരുന്നു. ഫോട്ടോകളുടേയും വീഡിയോകളുടേയും പേരും മോഡിഫിക്കേഷൻ ടൈമും ഷൂട്ട് ചെയ്ത ഡേറ്റ്/സമയ പ്രകാരം ആക്കാൻ നോക്കിയപ്പോൾ exiftool ആയിരുന്നു സഹായത്തിനെത്തിയത്. എക്സിഫ് ടൂളിന് -T എന്നൊരോപ്ഷനുണ്ട്, അതും ആവശ്യമുള്ള ടാഗ് നേമും കൊടുത്താൽ ആ ടാഗ് മാത്രം ഫയലിൽ നിന്ന് എടുത്തു തരും. 
exiftool -T -DateTimeOriginal IMG_3924.CR2
2011:09:18 15:52:28
നേരത്തേ പറഞ്ഞതുപോലെ പേരു മാറ്റി ഫയൽമോഡിഫിക്കേഷൻ ടൈം മാറ്റാൻ നോക്കിയപ്പോൾ, ടാഗിലെ സമയം ടച്ച് കമാന്റിനുപയോഗിക്കാവുന്ന രീതിയിലാക്കാൻ കുറേ മെനക്കെടേണ്ടിവരുമെന്നാണ് കരുതിയത്. എന്നാൽ -d എന്ന ഓപ്ഷനുപയോഗിച്ച് ഇഷ്ടമുള്ള ഡേറ്റ് ഫോർമാറ്റ് കൊടുക്കാൻ പറ്റുമെന്നു മനസ്സിലായി.
exiftool -d "%Y%m%d_%H%M.%S" -T -DateTimeOriginal IMG_3924.CR2 
20110918_1552.28
ആനന്ദലബ്ധിക്കിനിയെന്തു വേണം ;)
അടുത്തത് എംപീത്രീ ഫയലുകളിലെ ലിറിക്സ് ടാഗുമായി മല്പിടിത്തം നടത്തിയപ്പോൾ എക്സിഫ് ടൂൾ രക്ഷപ്പെടുത്തിയ കഥയാണ്. മുമ്പ് പാട്ടുകേൾക്കാൻ ഉപയോഗിച്ചിരുന്നത് അമറോക് മ്യൂസിക് പ്ലയറായിരുന്നു. അമറോക്കിന് id3 ടാഗിലുള്ള ലിറിക്സ് വായിക്കാൻ പറ്റില്ലെന്നുള്ളെത് ഒരു വലിയ പ്രശ്നമായിരുന്നു. അതു പരിഹരിക്കാൻ വേണ്ടി ഒരു അമറോക് പ്ലഗിൻ എഴുതാം എന്നു വിചാരിച്ച് നോക്കിയപ്പോൾ ഒരു വിധത്തിലും ലിറിക്സ് ഫയലുകളിൽ നിന്ന് എടുക്കാൻ പറ്റുന്നില്ല. (അന്നു ഐഡിത്രീയോടുള്ള കലിപ്പിലിട്ട പോസ്റ്റ് ഇവിടെ : http://primejyothi.blogspot.in/2013/12/id3-blues.html). id3info യും id3v2ഉം ഒക്കെ ഉപയോഗിച്ചു നോക്കിയപ്പോൾ‌ അതിൽ ലിറിക്സൊന്നും കിട്ടുന്നില്ല. അപ്പോഴാണ് എക്സിഫ് ടൂൾ ഓടിച്ചു നോക്കിയത്. ഔട്ട്പുട്ട് കണ്ട് കിടുങ്ങിപ്പോയി. ആ എംപിത്രീയിലുണ്ടായിരുന്ന സകല ടാഗുകളും അതു ലിസ്റ്റ് ചെയ്തു. ദാ ഉദാഹരണം (സ്ഥലം ലാഭിക്കാനായി ലിറിക്സ് കുറച്ച് കട്ട് ചെയ്തിട്ടുണ്ട്)
exiftool Pularmanjiloode-320-OnamwitheeNam2013.mp3
ExifTool Version Number         : 9.46
File Name                       : Pularmanjiloode-320-OnamwitheeNam2013.mp3
Directory                       : .
File Size                       : 14 MB
File Modification Date/Time     : 2014:02:04 14:46:32+05:30
File Access Date/Time           : 2014:03:26 18:37:13+05:30
File Inode Change Date/Time     : 2014:02:04 14:46:32+05:30
File Permissions                : rw-rw-r--
File Type                       : MP3
MIME Type                       : audio/mpeg
MPEG Audio Version              : 1
Audio Layer                     : 3
Audio Bitrate                   : 320 kbps
Sample Rate                     : 44100
Channel Mode                    : Stereo
MS Stereo                       : Off
Intensity Stereo                : Off
Copyright Flag                  : False
Original Media                  : False
Emphasis                        : None
ID3 Size                        : 187144
Title                           : Pularmanjiloode Alayaan
Artist                          : G Venugopal, G Nisikanth
Album                           : Onam with eeNam 2013
Recording Time                  : 2013
Track                           : 13
Comment (xxx)                   : (ID3v1 Comment) Visit [http://www.onam.eenam.com](http://www.onam.eenam.com) for
Lyrics                          :   പുലർമഞ്ഞിലൂടെ അലയാൻ, ... അലയാൻ, കുളിർ.കാറ്റിൽ മോഹം അലിയാൻ
Popularimeter                   :  Rating=0 Count=110
User Defined Text               : (FMPS_Playcount) 110
Genre                           : Festival Songs
Lyricist                        : G Nisikanth
Composer                        : G Nisikanth
Picture Mime Type               : image/jpeg
Picture Type                    : Front Cover
Picture Description             : Pularmanjoloode_final.jpg
Picture                         : (Binary data 183885 bytes, use -b option to extract)
Year                            : 2013
Comment                         : Visit [http://www.onam.eenam.com](http://www.onam.eenam.com) for
Date/Time Original              : 2013
Duration                        : 0:05:51 (approx)
അപ്പോൾ പറഞ്ഞു വന്നത് ഇനി ഏതെങ്കിലും ഫയലിൽ നിന്ന് മെറ്റാഡേറ്റ വേർതിരിച്ചെടുക്കണമെങ്കിൽ എക്സിഫ് ടൂൾ ഉപയോഗിച്ചു നോക്കാവുന്നതാണ്. ഏതൊക്കെ ഫയലുകൾ സപ്പോർട്ട് ചെയ്യുന്നെന്നറിയാൻ exiftool എന്നു മാത്രം റൺ ചെയ്യുക. ഏതെല്ലാം ടാഗുകൾ സപ്പോർട്ട് ചെയ്യുമെന്നറിയാൻ exiftool -list എന്നു റൺ ചെയ്യുക. എന്റെ സിസ്റ്റത്തിൽ ഏകദേശം മൂവായിരം ലൈനുകളിലായി പന്ത്രണ്ടായിരം ടാഗുകൾ ലിസ്റ്റ് ചെയ്തു ;)

December 12, 2013

ID3 Blues

I primarily use Amarok to play my music. One of my long standing gripe about Amarok is it's inability to read the lyrics from the id3 tags. This was not a major issue since the Amarok's lyrics plugins were able to fetch the lyrics from some external sites. However the online retrieval didn't work when I was listening to some new Malayalam songs[1] as the lyrics was not available online. That was when I tried to modify an Amarok plug in to read lyrics from the tags.

Since I had no experience with Qt Script, extracting lyrics using Qt Script  within the plug in was out of question. I thought of extracting the lyrics from the id3 tags using some utilities to a file and read it from the plug in. Tried to extract the lyrics using id3info and id3v2 but no lyrics[2]! Then I briefly considered writing my on program to extract the USLT frame scrapped the idea when I realized how crazy  the id3 format was.

Now I know why Amarok developers haven't implemented the feature to read the lyrics from the id3 tag. No wonder people consider it is easy to fetch lyrics from online instead of reading from the tags[3]. While reading about the id3 tags, I came across this post from Coding Horror - http://www.codinghorror.com/blog/2006/08/a-spec-tacular-failure.html I couldn't agree more. I guess it is high time someone come up with something simple tagging format instead of the id3 mess.

[1] The songs are from http://onam.eenam.com/. It is a nice album released under CC-BY-NC-ND license.
[2] To my surprise exiftool was able to extract the lyrics from the mp3 files. However I could not find a way to trigger the script that extract the lyrics. Finally I had to trigger the script from conky and the plugin was able to read the extracted lyrics from the output file. Since this was very inefficient, I manually copied the lyrics to Amarok's lyrics tab and solved the problem for the time being.
[3] Clementine & mpd fetch lyrics from online lyrics databases.