Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-28-2009, 06:10 AM
|
#1
|
|
Member
Registered: Feb 2006
Location: Warsaw, Poland
Distribution: Debian 6.0.4 & openSUSE 11.4
Posts: 117
Rep:
|
LAME - copy id3 tags
Hi
does anybody know option for LAME which will allow me to copy id3 tags (including picture) ?
I have written small bash script to lower bitrate of all mp3 files in the folder. When I copy my songs to mp3 player like iPod I don't need songs with 320kbps. Therefore I use lame in command line to change from 320kbps to 128kbps. This works fine. The problem is that new mp3 files lost all id3 tags but id3 tags are very useful with iPod.
I am looking for option when I execute LAME to copy all id3 tags. I found only options to set ID3 info, but maybe there is only one option I have to use with LAME.
regards
Rafal
|
|
|
|
12-29-2009, 12:21 AM
|
#2
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
You could use the id3v2 program to set many id3v2 tags, however it seems to just display data on APIC tags.
To be able to script extracting the picture from the original, and insert it into your new file, I think you would need to use id3lib to do it. Either directly (C++ programming) or via a scripting language with a id3lib library module.
Have a look at id3lib-ruby. http://id3lib-ruby.rubyforge.org/
This page has an example adding an attached picture frame.
|
|
|
|
12-29-2009, 02:02 PM
|
#3
|
|
Member
Registered: Feb 2006
Location: Warsaw, Poland
Distribution: Debian 6.0.4 & openSUSE 11.4
Posts: 117
Original Poster
Rep:
|
solved
Quote:
Originally Posted by jschiwal
You could use the id3v2 program to set many id3v2 tags, however it seems to just display data on APIC tags.
To be able to script extracting the picture from the original, and insert it into your new file, I think you would need to use id3lib to do it. Either directly (C++ programming) or via a scripting language with a id3lib library module.
Have a look at id3lib-ruby. http://id3lib-ruby.rubyforge.org/
This page has an example adding an attached picture frame.
|
Hi
In the meantime I have solved the problem as follows:
I have created small python script using mutagen.
Everything works perfectly.My script uses LAME to change bit rate and copies all tags I need (including picture). I have small problem with ZENITY (folder selection) but its another topic.
Apparently LAME does not support ID3 tags which is visible if I use it in terminal:
ID3v2 found. Be aware that the ID3 tag is currently lost when transcoding.
regards
Rafal
|
|
|
|
12-30-2009, 12:21 PM
|
#4
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Thanks for posting that link. I may incorporate it in my ogg2mp3 script. It used ogginfo to get the tags and then added the ones available in lame. Sounds like mutagen would work much better for this, if I'm not to lazy to edit it.
|
|
|
|
05-15-2011, 10:31 PM
|
#5
|
|
LQ Newbie
Registered: May 2011
Posts: 2
Rep:
|
Code to copy tags using mutagen
I had the same issue as Rafal and followed his advice to use mutagen. I hit a couple wrinkles so I thought I would paste my code here in case someone else googles to here looking for the same functionality. The slightly goofy arrangement lets this act like both a script (with -h or --help):
Code:
$ copy_id3.py --help
usage: copy_id3.py [-h] [-v] source_file destination_file
Copy ID3 tags from one mp3 file to another.
positional arguments:
source_file name of mp3 file to get tags from
destination_file name of mp3 file to copy tags into
optional arguments:
-h, --help show this help message and exit
-v, --verbose Display the resulting set of tags when done.
$
...and as a module (with help()):
Code:
>>> import copy_id3
>>> help(copy_id3)
Help on module copy_id3:
NAME
copy_id3 - Copy ID3 tags from one mp3 file to another.
FILE
/fs/bin/copy_id3.py
FUNCTIONS
copy_id3(srcname, destname, verbose=False)
Copy ID3 tags from srcname to destname.
argparse is available for older Pythons but was only added to the standard library in 2.7. Of course you can strip out the niceties. The core of this thing is only about six lines including the import. Have fun.
--Steve
Code:
#!/usr/bin/env python
""" Copy ID3 tags from one mp3 file to another. """
import mutagen
import argparse
def _main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'srcname', metavar='source_file', type=str,
help='name of mp3 file to get tags from')
parser.add_argument(
'destname', metavar='destination_file', type=str,
help='name of mp3 file to copy tags into')
parser.add_argument(
'-v', '--verbose', action="store_true",
help='Display the resulting set of tags when done.')
args = parser.parse_args()
copy_id3(args.srcname, args.destname, args.verbose)
def copy_id3(srcname, destname, verbose=False):
""" Copy ID3 tags from srcname to destname. """
src = mutagen.File(srcname, easy=True)
dest = mutagen.File(destname, easy=True)
for k in src:
dest[k] = src[k]
dest.save()
if verbose:
print "Copied ID3 tags from %(srcname)r to %(destname)r--result:" % locals()
print dest.pprint()
if __name__ == "__main__":
_main()
|
|
|
|
09-13-2011, 04:23 PM
|
#6
|
|
Member
Registered: Jan 2004
Location: USA
Distribution: Gentoo
Posts: 59
Rep:
|
FutureNerd, I'd like to employ your script... but get below python error
I've no exposure to python; any ideas?
python copyid3.py
File "copyid3.py", line 31
print "Copied ID3 tags from %(srcname)r to %(destname)r--result:" % locals()
^
SyntaxError: invalid syntax
|
|
|
|
09-16-2011, 08:44 PM
|
#7
|
|
LQ Newbie
Registered: May 2011
Posts: 2
Rep:
|
Quote:
Originally Posted by JurgyMan
FutureNerd, I'd like to employ your script... but get below python error
I've no exposure to python; any ideas?
python copyid3.py
File "copyid3.py", line 31
print "Copied ID3 tags from %(srcname)r to %(destname)r--result:" % locals()
^
SyntaxError: invalid syntax
|
JurgyMan: I guess something happened when you cut & pasted the text in-- check the indent of that line compared to on this page. Or it could be the previous line. Anyway, once you get that fixed you'll just get another error because you need to install mutagen, and maybe argparse, and you need to type in the from and to filenames.
Go to meetup.com and search for Python! Find someone there to help you getting started! Consume Python. Enjoy Python. Socialize only with those who do Python. Produce more Python.
--Steve
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:28 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|