Giter Site home page Giter Site logo

mp3agic's People

Contributors

athieriot avatar barkside avatar beckchr avatar coreequip avatar cyc1ingsir avatar dandanx avatar dependabot[bot] avatar dlundy avatar hanspog avatar hennr avatar hjellinek avatar kaliatech avatar mhor avatar mpatric avatar msendetsky avatar seamex avatar spikatrix avatar thekayani avatar tmzkt avatar ullenius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mp3agic's Issues

Add Maven instructions

Now that mp3agic is synced to Maven central, this should be mentioned in the project description, e.g.:

Releases are available via Maven central. To add a dependency to mp3agic, use

<dependency>
  <groupId>com.mpatric</groupId>
  <artifactId>mp3agic</artifactId>
  <version>0.8.x</version>
</dependency>

Non-unicode encodings

Hello,

Does this library support only Unicode encoding in tags? If no, how could I specify the encoding for reading?

Regards,
Igor

Remove plugin dependency

The POM lists a dependency to plugin maven-download-plugin. This makes mp3agic depending on "half of the internet". The plugin is available at central, so you may just remove it from the dependencies section.

Two failing tests on Windows

Encoding issue, only happens on Windows. Problem seems to be with the two failing tests, not the code.

  • BufferToolsTest.testShouldConvertBufferContainingHighAscii
  • EncodeTextTest.testShouldHandleBacktickCharacterInString

[junit] null expected:<T[]G> but was:<T[è]G>
[junit] junit.framework.ComparisonFailure: null expected:<T[]G> but was:<T[è]G>
[junit] junit.framework.ComparisonFailure: null expected:<T[]G> but was:<T[è]G>
[junit] at com.mpatric.mp3agic.BufferToolsTest.testShouldConvertBufferContainingHighAscii

No id3v2 tags in file

A mp3 i am trying to write id3v2 tags to has no id3v2 tags , but i haven't been able to find a way to set just some blank id3v2 tags on the file then work of that. I tried setting them to null, but that did not work which is to be suspected. Sorry if i am some obvious work around.

Support for text information frames with multiple strings in ID3v2.4

ID3v2.4 text information frames can contain multiple strings, whereas in ID3v2.3 and earlier they can only contain one. From the ID3v2.4 specification:

The text information frames are often the most important frames,
containing information like artist, album and more. There may only be
one text information frame of its kind in an tag. All text
information frames supports multiple strings, stored as a null
separated list, where null is reperesented by the termination code
for the charater encoding. All text frame identifiers begin with "T".
Only text frame identifiers begin with "T", with the exception of the
"TXXX" frame. All the text information frames have the following
format:

  <Header for 'Text information frame', ID: "T000" - "TZZZ",
  excluding "TXXX" described in 4.2.6.>
  Text encoding                $xx
  Information                  <text string(s) according to encoding>

Mp3agic will currently only return the first value when reading multi-values text information frames and will only allow you to set one value.

Gibberish result reading unicode tags using mp3agic in Java

I am trying to read tags of Russian songs in Java using mp3agic:

Mp3File song;
try {
song = new Mp3File(newURI);
if (song.hasId3v2Tag()) {
ID3v2 id3v2tag = song.getId3v2Tag();
title = id3v2tag.getTitle();
artist = id3v2tag.getArtist();
}
else if (song.hasId3v1Tag()){
ID3v1 id3v1tag = song.getId3v1Tag();
title = id3v1tag.getTitle();
artist = id3v1tag.getArtist();
}
}

However I get this "??-2????????? ?????" instead of this "Би-2Скользкие Улицы". What can I do to resolve this issue?

Is there any documentation?

The library seems very nice, but how do you expect people to know how to use it if there is no documentation? I cannot tell if I can use the library to extract PCM or raw audio data from mp3s, even though the description implies that it can.

remove tag

I grabbed the code because I was looking for some java code that would completely remove the ID3 tag. The readme indicate that this is supported but I don't see a method for it. How does one go about removing the tag. I expected to be able to do something like:

    Mp3File mp3in = new Mp3File("myMP3File");
    if(mp3in.hasId3v1Tag())
        mp3in.getId3v1Tag().remove();

How do I completely remove a tag?
Thanks

Release 0.8.2

How about releasing mp3agic 0.8.2?

Since version 0.8.1 half a year ago, there have been made some improvements and fixes that should be worth bumping a new release.

Add Support for Lyrics

This library would be awesome if it implemented the lyric section of the ID3 tag. I have a question over at Stack Overflow where I have tried to implement this, but the lyrics would not stick in the tag after saving the MP3. I added the code below to AbstractID3v3Tag.java. If there is anything I can do to help, let me know.

http://stackoverflow.com/questions/11924922/set-lyrics-in-mp3-id3v2-tag

Added Code to: AbstractID3v2Tag.java
//define lyric tag for id3v2
public static final String ID_TEXT_LYRICS = "USLT";
//get the lyrics from the tag
public String getLyrics() {
ID3v2TextFrameData frameData;
if (obseleteFormat) return null;
else frameData = extractTextFrameData(ID_TEXT_LYRICS);
if (frameData != null && frameData.getText() != null)
return frameData.getText().toString();
return null;
}
//set the lyrics in the tag
public void setLyrics(String lyrics) {
if (lyrics != null && lyrics.length() > 0) {
invalidateDataLength();
ID3v2TextFrameData frameData = new ID3v2TextFrameData(useFrameUnsynchronisation(), new EncodedText(lyrics));
addFrame(createFrame(ID_TEXT_LYRICS, frameData.toBytes()), true);
}
}

Getting a "Out of memory" error when initializing Mp3File instance

this is the stack trace
0 java.lang.OutOfMemoryError
1 at com.mpatric.mp3agic.BufferTools.copyBuffer(Unknown Source)
2 at com.mpatric.mp3agic.ID3v2Frame.unpackFrame(Unknown Source)
3 at com.mpatric.mp3agic.ID3v2Frame.(Unknown Source)
4 at com.mpatric.mp3agic.ID3v24Frame.(Unknown Source)
5 at com.mpatric.mp3agic.ID3v24Tag.createFrame(Unknown Source)
6 at com.mpatric.mp3agic.AbstractID3v2Tag.unpackFrames(Unknown Source)
7 at com.mpatric.mp3agic.AbstractID3v2Tag.unpackTag(Unknown Source)
8 at com.mpatric.mp3agic.AbstractID3v2Tag.(Unknown Source)
9 at com.mpatric.mp3agic.AbstractID3v2Tag.(Unknown Source)
10 at com.mpatric.mp3agic.ID3v24Tag.(Unknown Source)
11 at com.mpatric.mp3agic.ID3v2TagFactory.createTag(Unknown Source)
12 at com.mpatric.mp3agic.Mp3File.initId3v2Tag(Unknown Source)
13 at com.mpatric.mp3agic.Mp3File.init(Unknown Source)
14 at com.mpatric.mp3agic.Mp3File.(Unknown Source)
15 at com.mpatric.mp3agic.Mp3File.(Unknown Source)

Removing album art

There isn't currently an easy way to remove album art. I'm proposing adding a clearAlbumImage method to the ID3v2 interface and an implementation in AbstractID3v2Tag.

Add a download for each release

If you would add a jar including the lib and one including the source for each release as a download here at github people could use these downloads as dependencies in maven projects.

Properties not changing

Hello, i'm trying to use mp3agic to change the title property of my mp3 files, but the generated mp3 files are the same as the original files. The title property has not changed. I'm basically using the example in "Setting ID3v2 field values" section.
Here's my code:
...
File folderPath = new File(JOptionPane.showInputDialog("Folder Path:"));
File changedFilesFolder = new File(folderPath.getAbsolutePath()+File.separator+"ChangedFiles");
changedFilesFolder.mkdirs();
String fileNames[] = folderPath.list();
for(String fileName : fileNames)
{
if(fileName.endsWith(".mp3"))
{
Mp3File mp3file = new Mp3File(folderPath.getAbsolutePath()+File.separator+fileName);
ID3v1 id3v1Tag;
if (mp3file.hasId3v1Tag()) {
id3v1Tag = mp3file.getId3v1Tag();
} else {
// mp3 does not have an ID3v1 tag, let's create one..
id3v1Tag = new ID3v1Tag();
mp3file.setId3v1Tag(id3v1Tag);
}
id3v1Tag.setTitle(fileName);
mp3file.save(changedFilesFolder.getAbsolutePath()+File.separator+fileName);
}
}
...

What am I doing wrong?

filename can't be the same as source filename

If you edit tags and save the file without modifying the file name, mp3agic throws an IllegalArgumentException ("Save filename same as source filename")

This is a very common task and should be possible.

Handling of Unicode data

Handling of Unicode text blocks could be better. Also, support for Byte Order Mark (BOM) on Unicode text blocks should be added.

I have a problem with saving

I am making changes to the tags like the example in the docs "Setting ID3v2 field values"
but I when I am trying to save the file by the same name I am getting an exception (on android)
do I have to save the changes on a new file could I just apply them without creating a new file ?

Using mp3agic in my app

Hi

I am a newbie in Android development, and i am trying to use this library in my project, but i actually dont know about the junit, maven or ant procedures. Is there a library version of mp3agic as a jar so i can add it to my project?

Thanks

Setting multiple artists for the same music file.

Hey,

Thanks for the library, it is coming out to be really helpful for my project. I just had one question, is there a way to set multiple artists for the same mp3 file. In the documentation, it just shows one artist included in the id3v2 artist tag.

Cheers,
Yogesh

poor performances

I really appreciate how easy you've made the overall process of dealing with tags.
However, if I have done things correctly, reading a tag is extremely slow.
Reading tags on 400 tracks takes an average of 600ms per track (Android 4.4, Galaxy S4)...
for (Track track : tracklist){
mp3file = new Mp3File(track.getPath());
if (mp3file != null && mp3file.hasId3v2Tag()) {
mp3file.getId3v2Tag();
}
}

Any idea to speed up the process ?

thanks

Extracting ID3v2.3 tag data after editing with program Mp3tag

I am in the process of testing an Mp3 metadata extraction application for audiobook files based upon the mp3agic library. When I did my unit testing, I used an input mp3 file that had never been edited using the Mp3tag tag editor (http://www.mp3tag.de/en/). The application met all unit test criteria and I moved on to complete my testing.

Unfortunately, when I did a volume test, most of my audiobook Mp3 files had been edited using the Mp3tag tag editor. I had used the editor to change the genre and in many cases to add cover art to the Mp3 files. When processing these edited Mp3 files, my application is not finding the metadata from the ID3v2.3 tag. I am declaring my variable using the ID3v2 interface. I am calling the methods in that interface. I have confirmed that I am working with an instance of the class ID3v23Tag. Yet, most of the getters() are returning null. This includes artist, title, album, year, comment, publisher, original artist, copyright, URL, and encoder. The getters() for track, genre, and Mime type are returning values. My only thought is that the mp3agic library is sensitive to some change that is being made to the file by the Mp3tag editor.

When I re-edit the problem files using the Mp3tag editor, that application reports that there is an ID3v2.3 tag. It also finds all of the metadata from that tag. So, I know that the metadata is not lost from the file. It just seems to not be findable by the mp3agic library. Also, other user agents like Itunes and Windows Media Player seem to find this ID3v2.3 metadata just fine too. So, whatever format the Mp3tag editor is writing these files in cannot be that non-compliant.

Do you have any ideas about solving this issue?

Thanks for your help.

Kevin

Save metadata on the same file, not in another

Hi, I started editing the mp3 tags using mp3agic and it worked well.
But I am a little dissapointed that when the metadata is to be saved it has to go to a new file, not the same file.
I know that to save the edited tags in the same file is possible as VLC, Winamp and other programs do it. And I want the program I am doing to do it as well.
Is that possible using mp3agic? if not, can you suggest me another library that is able to do it?
I hope and thank your answers.

Override hashCode() when you override equals()

As Java SDK suggests, you should override hashCode() too when you override equals(). This speeds up your code a bit, and most importantly, your code will not produce compiler warnings.

Support for TXXX Frames

Hi,
I am missing Support for User defined text information frames in mp3agic.
I am using Amarok and it stores FMPS_Playcount, FMPS_Rating and some strange FMPS_Rating_Amarok_Score in my Files.
I would like to access this information in my Java Program and have already managed to get this Information in mp3agic but there is no way how this could should fit into the Structure of mp3agic.
In the Frameset you already store the different entries with the Same ID 'TXXX' but the Data cannot be accessed.
First I thought, that when unpacking the Frame, that its ID should be set to 'TXXX:whatever'. But the Problem is, that 'whatever', the Description of the User Defined Information is in the Same encoding as the Value and therefor should not be mixed with the ID.
Have you ever thought of how this should be implemented. I would work it out according to what we agree.

My experience in interpreting those byte[] according to the Specs of http://id3.org/id3v2.3.0#User_defined_text_information_frame is very low and I am sure that I will need your support for that implementation, but I would be glad If I could contribute to the Project.

UTF-8 characters causing NullPointerException when trying to set ID3v2Tag property

When the string sent to any of the "setXXXX" methods of ID3v2Tag contains a UTF-8 character outside of the ASCII range, I am getting a NullPointerException down in one of the frame data classes.

Here is a sample unit test that demonstrates the problem:

    @Test
    public void testUTF8AlbumData() throws Exception {
        // Set a string with a UTF-8 apostrophe in it,
        // http://www.fileformat.info/info/unicode/char/2019/index.htm
        String title = "The Album’s Name";
        Mp3File mp3File = new Mp3File("///path/to/some/file.mp3");
        ID3Wrapper tag = new ID3Wrapper(mp3File.hasId3v1Tag() ? mp3File.getId3v1Tag() : new ID3v1Tag(),
                mp3File.hasId3v2Tag() ? mp3File.getId3v2Tag() : new ID3v24Tag());

        // This generates a NullPointerException down in frame data
        tag.setAlbum(title);
    }

The stack trace that this test generates looks like this:

java.lang.NullPointerException
    at com.mpatric.mp3agic.ID3v2TextFrameData.getLength(ID3v2TextFrameData.java:37)
    at com.mpatric.mp3agic.ID3v2TextFrameData.packFrameData(ID3v2TextFrameData.java:26)
    at com.mpatric.mp3agic.AbstractID3v2FrameData.packAndUnsynchroniseFrameData(AbstractID3v2FrameData.java:21)
    at com.mpatric.mp3agic.AbstractID3v2FrameData.toBytes(AbstractID3v2FrameData.java:29)
    at com.mpatric.mp3agic.AbstractID3v2Tag.setAlbum(AbstractID3v2Tag.java:389)
    at com.mpatric.mp3agic.ID3Wrapper.setAlbum(ID3Wrapper.java:90)

From my reading of the code, it looks like AbstractID3v2Tag is hard-coding the text encoding as ISO-8859-1 when it creates an EncodedText instance in each of its setters.

reorganize unit tests

This issue exists to make it more transparent that all unit tests are planned to get rewritten as spock [0] tests.
The long term goal is to increase the unit test coverage and substitute the JUnit 3 tests with more readable spock tests.

You may also raise your voice here if you have good reasons to criticise this decision.

If you like it or simply want to play with spock tests, patches are welcome in the spock_unit_testing branch [1].

0: http://code.google.com/p/spock/
1: https://github.com/mpatric/mp3agic/tree/spock_unit_testing

Andoid

Hello, its possible to use mp3agic in an android project?
Thank you

Logical bug?

File: AbstractID3v2Tag.java
Line: 526

This is the line:
if (description != null & description.length() > 0) {

It should have logical AND instead of bitwise AND:
if (description != null && description.length() > 0) {

Add method to determine ID3v2 minor version

We should add a method like ID3v2.getMinorVersion() to return an integer indicating the ID3 v2 minor tag version number (e.g. 3 for ID3 v2.3).

This makes sense because some ID3v2 API methods may have different behavior, depending on the tag version. For example, the user may provide a genre as free-text to a v2.4 tag only.

Can't figure out the save function

Hi guys,

I know this might seem like a dumb question, but I'm in the middle of writing a Java Swing GUI application that functions like MP3Tag (for educational purposes) and I'm currently writing my saveTag method to save the newly written tag data into the imported MP3 file.

savetag method source

This is my saveTag method, commented to get the logic across. (see above)

gui_example

This (see above) is a picture of the GUI in action, the new tag data is taken from the JComboBox components and is set into the tag data, and all of this works. However, when the code gets to the Mp3File.save(); function, it doesn't seem to create a new file, and it continues to delete the original just fine. Any help with understanding how to use the save function would be very much appreciated. Thank you!!

How to get the Encoder

Hi, is there any way to know which encoder has been used to encode the MP3 File?
Something like a method mp3File.getEncoder() which returns 'Lame 3.99', 'Lame 3.95', 'Xing' etc?
I've seen this information is inside the file (and is shown for example in EncSpot), but i really have no idea on how to get it.
Anyway, is a great library.
Giorgio

problem with setAlbumImage()

I write a code to save album image into an mp3 file. but seems unable to save image tag.
code:

        byte[] content = readImageContentFromFile("cover.jpg");
        Mp3File mp3file = new Mp3File("xxx.mp3");
        ID3v2 id3v2Tag;
        if (mp3file.hasId3v2Tag()) {
            id3v2Tag = mp3file.getId3v2Tag();
        } else {
            // mp3 does not have an ID3v2 tag, create one
            id3v2Tag = new ID3v24Tag();
            mp3file.setId3v2Tag(id3v2Tag);
        }
        id3v2Tag.setAlbumImage(content, "image/jpg");
        mp3file.save("xxx1.mp3");

File constructor and/or File getter

I am very new with Java programming so thanks in advance for humoring me.

Is there any reason not to have an Mp3File constructor that accepts a File object and/or a getFile() method that returns a File object?

Right now my code looks like this...

Collection<File> files = FileUtils.listFiles(directory, extensions, true);
for (File file:files) {
  Mp3File mp3file = new Mp3File(file.getAbsolutePath());
  // do stuff
  System.out.println("Filename: " + file.getName());
}

I would like to be able to do this...

Collection<File> files = FileUtils.listFiles(directory, extensions, true);
Mp3File[] mp3s = new Mp3File[files.length]
for (int i=0; i<mp3s.length; i++) {
  mp3s[i] = new Mp3File(files[i]);
}
for (mp3:mp3s) {
  // do stuff
  System.out.println("Filename: " + mp3.getFile().getName());
}

problem with getAlbumImage ()

when using this method returns null for me all the songs that I try even knowing that they have cover

public Musica getMusica(String path) {

    Musica musica = new Musica();
    // caminho
    musica.setCaminho(path);
    Mp3File mp3file;
    try {
        mp3file = new Mp3File(path);
        // duração
        musica.setDuracao((int) mp3file.getLengthInSeconds());

        if (mp3file.hasId3v1Tag()) {
                      //load the data in the object Musica
                    } else if (mp3file.hasId3v2Tag()) {
            ID3v2 id3v2Tag = mp3file.getId3v2Tag();

            //load the data in the object Musica

            byte[] imageData = id3v2Tag.getAlbumImage();

            if (imageData != null) {
                Image img = ImageIO
                        .read(new ByteArrayInputStream(imageData));
                musica.setImage(img);



            }
        } else throw new UnsupportedTagException();

    } catch (UnsupportedTagException e) {

        musica.setArtista("Desconhecido");
        musica.setAlbum("Desconhecido");
        musica.setTitulo(path.substring(path.lastIndexOf("\\") + 1,
                path.lastIndexOf(".") - 1));
        musica.setGenero("Desconhecido");

    } catch (InvalidDataException | IOException e) {
        System.out.println("kk");
        return null;
    }

    return musica;

}

remove ant build files

As mp3agic is a maven project since quite a while it seems reasonable to remove the ant files.
This issue only exists as kind of a warning and to ask if anyone still uses ant for a good reason.

Ant will removed in >2 weeks if no good reasons occur.

Support German Umlauts

I just found out, that German umlauts in the path when instantiating the Mp3File are not supported. (ö, ä, ü, Ö, Ä, Ü, ß)

cannot find symbol class NoSuchTagException com.mpatric.mp3agic.ID3v23Tag

Hi,
I'm trying to use mp3agic api in a netbeans project. I have no compilation errors though when I try to run the example code, I am getting an error when trying to do a new Mp3File. In debug mode, I get up to (but not into)
id3v2Tag = ID3v2TagFactory.createTag(bytes);
But, then a NoSuchTagException exception is raised that apparently is not found, though the class does exist in the package com.mpatric.mp3agic!

Could you please help me? I am new to Java but I have coding experience ...

Here is the error message I get:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol: class NoSuchTagException
location: class com.mpatric.mp3agic.ID3v23Tag
at com.mpatric.mp3agic.ID3v23Tag.(ID3v23Tag.java:12)
at com.mpatric.mp3agic.ID3v2TagFactory.createTag(ID3v2TagFactory.java:10)
at com.mpatric.mp3agic.Mp3File.initId3v2Tag(Mp3File.java:256)
at com.mpatric.mp3agic.Mp3File.init(Mp3File.java:68)
at com.mpatric.mp3agic.Mp3File.(Mp3File.java:57)
at com.mpatric.mp3agic.Mp3File.(Mp3File.java:41)
at musicchecker.Main.main(Main.java:60)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.