Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating tags corrupts audio files #11

Closed
ravicious opened this issue Dec 6, 2020 · 4 comments
Closed

Updating tags corrupts audio files #11

ravicious opened this issue Dec 6, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@ravicious
Copy link

ravicious commented Dec 6, 2020

I've been trying to use mp4ameta in my side project. I noticed that a simple action of setting the artist and album corrupts the file. It doesn't happen with every m4a file though.

Here's a zip file with examples (I'll delete the link later). The first two I bought from iTunes and Bandcamp, the third one is from a site with public domain sounds. Run the following code on the three of them and notice that the first two stop being playable, but the third one still works:

let examples = ["example1.m4a", "example2.m4a", "example3.m4a"];

for example in &examples {
    let mut tag = mp4ameta::Tag::read_from_path(example).unwrap();
    tag.set_artist("Foo");
    tag.set_album("Bar");
    tag.write_to_path(example).unwrap()
}

Is this a bug in the library or am I doing something wrong?

@saecki
Copy link
Owner

saecki commented Dec 6, 2020

Thanks for reporting, I could reproduce your issues and will get to it asap.

@saecki saecki added the bug Something isn't working label Dec 6, 2020
@saecki
Copy link
Owner

saecki commented Dec 7, 2020

The problem is that in the files that get corrupted the mdat atom comes after the movie atom, which contains the metadata and references to the media data in mdat. Changing the size of the metadata should update these references if that's the case but doesn't.

@saecki saecki closed this as completed in 227d178 Dec 10, 2020
@saecki
Copy link
Owner

saecki commented Dec 10, 2020

Sorry if this took a while. The latest commit should fix files being corrupted. I will do some cleanup and then publish a new version.

@ravicious
Copy link
Author

No problem, thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants