Linux - SoftwareThis 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.
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.
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.
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.
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.
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.
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()
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.