View previous topic :: View next topic |
Author |
Message |
javeree_work Tux's lil' helper

Joined: 13 Apr 2005 Posts: 84
|
Posted: Mon Mar 20, 2006 3:26 pm Post subject: extract APIC from an MP3 |
|
|
I have many MP3's that contain an 'assorted picture' (APIC) in the id3 tags. I am looking for a way to extract these pictures from the mp3 using command line. That would allow me to change the background of my desktop to the asssociated picture of the song that is currently playing.
I thought id3info could do that, but id3info only shows that an APIC frame exists and what the size and type of the embedded picture is. I have not yet found a way to actually extract the picture as a binary that I could dump into a file or a pipe
I've googled around, but until now, the only thing I found would involve programming in perl (as yet unknown to me) and using an MP3::Tag library.
I am still hoping for a solution that does not involve learning a new programming language. Does anyone have a suggestion (or is willing to show me a perl script that can do
Code: | ExtractFrame --APIC mp3file > imagefile |
or something similar ? |
|
Back to top |
|
 |
tmf Tux's lil' helper

Joined: 10 May 2005 Posts: 76 Location: Warsaw, Poland
|
Posted: Mon Mar 20, 2006 7:33 pm Post subject: |
|
|
I wont be able to provide exact solution, but take a look at http://pyid3lib.sourceforge.net/doc.html, section "Attached pictures". There is example how to get an APIC picture using python console.
Some time ago for some reasons I wanted to clear all APIC pictures from all of my mp3 files, I made a very simple script for that:
Code: |
#!/usr/bin/python -O
import pyid3lib, glob, sys
listMP3=sys.argv[1]+'/'+'*.[mM][pP]3'
list=glob.glob(listMP3)
for i in list:
x = pyid3lib.tag(i)
for j in x:
if j['frameid']=='APIC':
bDobry=1
else:
bDobry=0
if bDobry==1:
print i
indexApic = x.index('APIC')
del x[indexApic]
x.update()
|
Don't run it as it _clears_ APIC pictures. It takes on input directory name with MP3 files to work on.
It took me an hour to write it without any previous knowledge of python. I'm sure it will be easy to adapt it to your needs.
And... there is quite different solution. If you use amarok, you can use Desktop script http://kde-apps.org/content/show.php?content=20293 to do the job.
tmf |
|
Back to top |
|
 |
javeree Guru

Joined: 29 Jan 2006 Posts: 462
|
Posted: Mon Mar 20, 2006 8:47 pm Post subject: |
|
|
Thanks to your pointer I wrote the below script which does what I want. It is very non-foolproof, but good enough for now. It's also an encouragement to have a deeper look at python sometime
Code: | #!/usr/bin/python -O
import sys, pyid3lib
mp3file = sys.argv[1]
id3tag = pyid3lib.tag(mp3file)
d = id3tag[id3tag.index('APIC')] # this finds the first embedded picture in the tag
sys.stdout.write( d['data'] )
sys.stdout.close() |
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|