saecki / mp4ameta Goto Github PK
View Code? Open in Web Editor NEWA library for reading and writing iTunes style MPEG-4 audio metadata
License: Apache License 2.0
A library for reading and writing iTunes style MPEG-4 audio metadata
License: Apache License 2.0
Hello again, after the previous fix for #1 I am now encountering two distinct kinds of errors with all the M4A files in my collection, either
Parsing: Typed data head to short
or
UnknownDataType(21): Unknown datatype code
I am providing two test files, one that produces each of the above errors, at https://github.com/rayrrr/rust-mp4ameta/tree/master/test_files so please advise. Thank you again for your efforts.
With mp4ameta v0.11.0, I edited this file's artworks
. I believe it ran tag.take_artworks()
and then tag.set_artworks(Vec::new())
, so it should just have removed the artworks
.
Aero Chord - 4U copy.m4a.zip
On 0.11.0, read_from_path()
works fine on the file, but on the master branch, it results in this error:
Error parsing moov: Error parsing udta: Error parsing meta: Error parsing ilst: Error constructing meta item 'covr', missing data atom
The type of the sample rate depends on the range of possible values, but neither on the platform nor the CPU architecture. The return type usize
for SampleRate::hz()
is not a good match. Using u32
with a known size would be a better choice.
I'm seeing a few errors like the one below when scanning my music collection in Polaris. I attached an example file causing the issue. bad.zip
Parsing: Error reading moov: Error reading udta: Error reading meta: Error reading ilst: Error reading ©ART: Error reading data: Data already parsed
I am also getting a few of these, even though foobar2000 can show metadata for these files just fine:
NoTag: File does not contain MPEG-4 audio metadata
Hi,
First let me thank you for this crate. I was looking for a long time for a crate to write m4a metadata in rust (I had to write my current utility for managing work/movement in classical music in python because of that 🙁). I was really happy a couple of days ago when during my occasional searches I found this crate.
I'm trying to create a PR for supporting work / movement. This includes 5 new tags:
‘\xa9wrk’
- work name (string)‘\xa9mvn’
- movement name (string)‘\xa9mvc’
- movement count (number)‘\xa9mvi’
- movement index (number)shwm
- show work movement flag (as integer, 1 is true)I have zero knowledge about reading/writing binary data. I managed to make it read a couple of these tags. For example the data is printed like this in the test:
Atom{ ©mvc, 0, Content::Atoms{ [
Atom{ data, 0, Content::TypedData{ Reserved{ [0, 4] } } },
] } },
Atom{ ©mvi, 0, Content::Atoms{ [
Atom{ data, 0, Content::TypedData{ Reserved{ [0, 1] } } },
] } },
Atom{ ©nam, 0, Content::Atoms{ [
Atom{ data, 0, Content::TypedData{ UTF8{ "Sonata in D minor for cello and piano, op. 40: I. Allegro non troppo - Largo" } } },
] } },
I have no idea why movement index/count is parsed as 2 items but the value is true.
I would appreciate any pointers on how to write the set_*
functions for the following data types:
cpil
)my main resource for the above tags is the mutagen documentation.
Thank you very much in advance
How could I access atoms that all have the same Ident
"----" and are distinguished by the string in the nested mean atom? Many commonly used fields are encoded using these kind of atoms.
http://atomicparsley.sourceforge.net/mpeg-4files.html
There is also another form of tagging that iTunes uses internally by a few inaccessible tags. Called the reverse DNS style (or something along that line), this form is pictured below:
Atom ---- @ 39852 of size: 72, ends @ 39924
Atom mean @ 39860 of size: 28, ends @ 39888
Atom name @ 39888 of size: 16, ends @ 39904
Atom data @ 39904 of size: 20, ends @ 39924where the mean atom carries the reverse DNS domain (com.apple.iTunes) & the name atom carries the descriptor for the contents of the data atom.
Btw, thanks for your work! Exactly what I need for tag synchronization including support for multi-valued fields. I just started to use this crate.
First, thanks for making this crate!
I can set the artwork(s) using the various set_artwork
functions, but there doesn't appear to be any way to identify whether I'm setting a front cover, back cover, etc? Am I missing something here? Can it be done?
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?
For accessing the following read-only properties I need to read the file twice using the mp4 crate:
Would it be possible to provide them for consistency and completeness?
I've written a Rust program to clean meta data in my large and diverse music library, all in ALAC format.
For certain files, the write_to_path() function fails with Mp4TagError(Io(Error { kind: UnexpectedEof, message: "failed to fill whole buffer" }): Error reading atom length). This is persistent for the files in question.
I see no error writing the same tags in other software e.g. kid3-cli.
Hi,
I love this library, fantastic for my music player I'm building at the moment. One feature I wish it were missing were implementations of the sort order tags, more specifically artist sort ("soar") and album artist sort ("soal").
Thank you for reading :)
Hi, thank you for creating this library. It's a joy to use, and lets me add MP4 support to my music player extremely fast. And it was consistently recommended by GPT-4, while I was researching my options.
Hi, I'm getting this error from Tag::read_from_path()
: Parsing: Read length of mdat which is less than 8 bytes: 1
. iTunes, QuickTime, VLC and music-metadata are able to handle the file just fine.
I tested mp4ameta on 4 of the m4a
s I have, and this issue turned up, so not sure how common this error would be for the other 4000 m4a
s I've got.
Can send over the m4a privately if you need it.
Is there a way of reading chapters info from m4b files?
Reproduction code
fn main() {
let data = [0, 0, 0, 1, 102, 116, 121, 112, 0, 132, 255, 255, 255, 255, 0, 132];
let mut data = std::io::Cursor::new(data);
let tag = mp4ameta::Tag::read_from(&mut data);
}
Results in
memory allocation of 37436171902451828 bytes failed
zsh: abort (core dumped) cargo run
Hey, got a question about the ©day
tag. Feel free to close if you don't know or want to answer.
In most places, it looks like ©day
is just mentioned as being for the year. However, it's of course named ©day
and the Movie Atoms specification describes ©day
as Date the movie content was created
.
Is it valid to enter info like month/date/time in ©day
, and if so, what format?
ID3v2.4's TDRC
tag lets you optionally include month, date and time in the format yyyy-MM-ddTHH:mm:ss
.
Thank you for the development of this crate which is very helpful to me!
Music downloaded from mora (one of the major music stores in Japan) usually have .m4a
extensions, but its filetype signature within the file data is not recognised by rust-mp4ameta.
When calling mp4ameta::Tag::read_from_path("foo.m4a").unwrap();
:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidFiletype("mp42\u{0}\u{0}\u{0}\u{1}isommp423gp5"): Invalid filetype.'
However, they really contain valid m4a tags, and I was able to parse them by changing core::atom::VALID_FILETYPES
to [&str; 6] = ["M4A ", "M4B ", "M4P ", "M4V ", "isom", "mp4"]
(appeded "mp4"
). I am not sure whether this is a standard fieltype signature. If it is, could it be added to VALID_FILETYPES
? If not, is there any possibility for having a function for "force-parsing" the tags regardless of the file type?
Hi @saecki thank you for your work here! We would like to use this crate in another project, for reading existing atoms/tags on M4A files in a personal music library. See agersant/polaris#82
However, it returns None
for all atoms/tags. This simplified example based on your README is panicking on the 2nd unwrap:
fn main() {
let tag = mp4ameta::Tag::read_from_path("music.m4a").unwrap();
println!("{}", tag.artist().unwrap());
}
Any information would be helpful.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.