Author Topic: NEW: Tags Library  (Read 51682 times)

Sascha

  • Guest
Re: NEW: Tags Library
« Reply #50 on: 5 Dec '14 - 00:05 »
Hi,

yes, this works very well!
Both taggers now show my custom atoms and the hex view looks quite identically now. With these iTunes atom type I can now use atom names >4 bytes without problems?

Need now to change some code because FindAtom now works different... I will check this... Thanks a lot!!  ;D


Sascha

  • Guest
Re: NEW: Tags Library
« Reply #51 on: 5 Dec '14 - 01:22 »
Works fine :) Except one point...

I get a RangeCheck error if I saved the tag with Godfather! Perhaps Godfather makes someting wrong... The exception occures in

Code: [Select]
function TMP4Atomname.GetAsText: String;
[...]
SetLength(Bytes, Data.Size - 4);  // Data.Size is 0

Would be more robust if you catch this if any tag editor did crazy things... I put a zip with both example files on http://www.musican.net/data/bin/test.zip
Writing and changing everything with Mp3Tag work really fine!

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #52 on: 5 Dec '14 - 03:11 »
Good to hear that it works now! :)

Yes, sorry, I already fixed that, please try the update: MP4TagLibrary.zip

Sascha

  • Guest
Re: NEW: Tags Library
« Reply #53 on: 5 Dec '14 - 12:19 »
Now its in an endless loop in function MP4mdatAtomLocation(MP4Stream: TFileStream): Int64; after a call  to fMP4.savetoFile() . AtomName is 0,0,0,0 and Size is 0

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #54 on: 5 Dec '14 - 18:21 »
Please give a download link for that mp4 file before tagging if possible! Thank you!

Sascha

  • Guest
Re: NEW: Tags Library
« Reply #55 on: 5 Dec '14 - 21:24 »
Before tagging? The endless loop occures while I try to add a custom field... I'm not sure about the "life cycle" of this file... what taggers are working on it before and if the file has standard tags. But independend of the files state, the tagging engine should never end in an endless loop...
It's on the usual place on http://www.musican.net/data/bin/test.zip


3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #56 on: 5 Dec '14 - 21:45 »
The file you posted is already corrupted. Sorry, I'll try to completely rewrite the mp4 tag writing part. Hopefully in a couple of weeks or next year. The writing part is very nasty in MP4 Tag Library, I'll try to improve it.

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #57 on: 7 Dec '14 - 23:06 »
Ok. Here's a new beta version: MP4TagLibrary.zip

With completely re-written tag writing. It's not tested at all, use the save function only on test files, and keep them, so if the writing fails, please send them to me, the one before using the save function on it! I'll test it later more, but your testing would be helpful also.

Thank you!

Sascha

  • Posts: 4
Re: NEW: Tags Library
« Reply #58 on: 8 Dec '14 - 01:58 »
Hey,

tested it again. Now after writing a custom atom the complete file seems to be corupt. MPC (MediaPlayerClassic) don't play it anymore. In Hex view the complete file is different.

http://www.musican.net/data/bin/before.zip
http://www.musican.net/data/bin/after.zip

The endless loop is still there with the corupt file from last try.

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #59 on: 8 Dec '14 - 20:33 »
Ok, here's an update: MP4TagLibrary.zip

There was a bug in stco/co64 updating which results a skipping file while playing. Hopefully it's fixed now.
Also now 64bit sized stco/co64 atoms are supported, and there are some small fixes too.

Regarding the endless loop thing: if an MP4 file gets corrupted then there's no easy way of fixing it. Data could be overwritten/lost so that can not be recovered.

Sascha

  • Posts: 4
Re: NEW: Tags Library
« Reply #60 on: 9 Dec '14 - 03:03 »
Hi,

- This is a smaller version number than the last update had!?
- It takes now about 6 seconds to write the tags to a single file.
- And it doubles the size of the audio file each time after saving the tag!

Did you test anything of your last changes?

Quote
Regarding the endless loop thing: if an MP4 file gets corrupted then there's no easy way of fixing it. Data could be overwritten/lost so that can not be recovered.

We are talking about an endless loop in your code! If the the MP4 file is corrupt detect it and raise an exception but don't end in an endless loop!

For now I will stop working with your tag libs. Please take some more time to get it stable and do some detailed tests. A notice that it is in beta state would be helpful for others too.

Regards,Sascha

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #61 on: 9 Dec '14 - 05:54 »
Sorry, didn't care about the version number, I changed it to be in sync with my backup, didn't know its important.

Sorry about the file size doubling too, yes I checked with the file you posted, I wrote that it's a beta version, and also that it is very little tested.
The problem was that the code was not expecting empty atoms. If you mind you can download the update from the link again. And it's still very little tested though.

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #62 on: 9 Dec '14 - 21:36 »
Ok. The version tested with a dozen of exotic MP4 files, and fixed all the issues with them, is here: MP4TagLibrary.zip

I would still recommend to use the writing function only on test files.

Regarding the endless loop issue: now there is checking of the reported atom sizes, but will not check when getting the size of the mdat atom, the reason is that if an MP4 file is only partially downloaded then it still possible to tag it, even it reports an invalid atom size. There is a MP4TagLibraryFailOnCorruptFile global variable which is False by default and while reading the tags will raise an exception if an atom size is invalid, but still keep possibility of writing tags to these partially downloaded files. To always reject invalid files set this global variable to True.
« Last Edit: 9 Dec '14 - 21:41 by 3delite »

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #63 on: 11 Dec '14 - 20:38 »
The Tags Library package has been updated with the new MP4 Tag Library.
Download link in the first post.

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #64 on: 12 Dec '14 - 21:15 »
An update is up in the first post:

  • Fixed loading of APE tags with 0 length field values
  • Fixed APE tags GetAsText functions with illegal UTF-8 field values, for the second try now they are read as ANSI

TCount

  • Posts: 30
Re: NEW: Tags Library
« Reply #65 on: 14 Dec '14 - 11:34 »
I run the demo "Tutorial DLL" ...
When you open any file I receive an error:
"Сorrupted MP4 file. Atom name:    "
------------
I open FLAC-files:
Code: [Select]
TagsLibrary_Load(Tags, PChar(FileName), ttAutomatic, True);
- Error "Сorrupted MP4 file. Atom name:    "
Code: [Select]
TagsLibrary_Load(Tags, PChar(FileName), ttFlac, True);
- it's ok
« Last Edit: 14 Dec '14 - 11:45 by TCount »

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #66 on: 15 Dec '14 - 20:42 »
Please try the update available in the first post.

Thank you for reporting this!

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #67 on: 19 Dec '14 - 00:29 »
Some updates to the .dll version:

  • modified all tag get/set "Ex" functions to work with specific tag data structures, please see the usage in the ReadMe
  • fixed TagsLibrary_GetCoverArt() 'PictureFormat' with 'ttID3v2' and 'ttFlac'

Delphi class hasn't changed, no need to update for Delphi users.

TCount

  • Posts: 30
Re: NEW: Tags Library
« Reply #68 on: 19 Dec '14 - 16:00 »
Please add to the library function for streaming.
something like: TagsLibrary_LoadFromStream()

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #69 on: 20 Dec '14 - 00:20 »
You mean to load from a TStream? If so, I'm afraid it's not possible for all the formats, there are LoadFromStream() functions for particular tags where it's possible.
But now I see you are talking about the .dll version? What kind of stream?

TCount

  • Posts: 30
Re: NEW: Tags Library
« Reply #70 on: 20 Dec '14 - 16:05 »
You mean to load from a TStream? If so, I'm afraid it's not possible for all the formats, there are LoadFromStream() functions for particular tags where it's possible.
But now I see you are talking about the .dll version? What kind of stream?

I'm using Delphi.
I download files from the Internet in TMemoryStream ...
Before you save the file I want to edit the tags in this stream.

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #71 on: 20 Dec '14 - 21:43 »
But why don't you edit the tags after saving the file?

EDIT: Here's a beta update (not tested) which has a TagsLibrary_LoadFromMemory() function: Tags Library 1.0.29.50 beta.zip

No saving though.
« Last Edit: 21 Dec '14 - 01:47 by 3delite »

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #72 on: 22 Dec '14 - 00:14 »
Ok, here's an update: Tags Library 1.0.29.51 beta.zip

Fixed loading from memory, and managed to convert all the save functions to support saving to memory. :)

It's a beta version, not tested, only a little with Flac, ID3v2 (MP3) and MP4 files. Please keep backup copies of your files when yo use the save function - this also means the normal file save function too, because the saving code has been modified.

For Delphi, usage:

Code: [Select]
var
    Tags: HTags;
    Data: TMemoryStream;
    PFileData: Pointer;
    DataSize: UInt64;
    SaveHandle: Pointer;
begin
    Tags := TagsLibrary_Create;
    Data := TMemoryStream.Create;
    Data.LoadFromFile(FileName);
    TagsLibrary_LoadFromMemory(Tags, Data.Memory, Data.Size, ttAutomatic, True);
    ...list, modify tags as usual...
    TagsLibrary_SaveToMemory(Tags, Data.Memory, Data.Size, ttMP4, PFileData, DataSize, SaveHandle);
    //* Put back the saved data to the stream
    Data.Clear;
    Data.Write(PFileData^, DataSize);
    Data.SaveToFile('H:\Test.mp4');
    //* Free the data that was generated by the save function
    TagsLibrary_FreeSaveHandle(SaveHandle);
    FreeAndNil(Data);
    TagsLibrary_Free(Tags);
end;

There is one note: 'ttAutomatic' is not yet supported when using TagsLibrary_SaveToMemory() you have to specify a tag format.

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #73 on: 28 Dec '14 - 21:45 »
New beta is available: Tags Library 1.0.29.52 beta.zip

To be complete, added function for removing tags from a memory "file", also there are other little improvements.

  • TagsLibrary_RemoveTagFromMemory

Usage is the same as for the TagsLibrary_SaveToMemory() function.
« Last Edit: 29 Dec '14 - 00:46 by 3delite »

3delite

  • Posts: 869
Re: NEW: Tags Library
« Reply #74 on: 4 Jan '15 - 19:54 »
Version 1.0.31.54 is officially released.

  • Load/save/remove tags from memory "files"
  • Added automatic file format detection (and thus tag format choosing) for the save functions for the following file formats: affAPE, affFlac, affOggFlac, affMPEG, affMP4, affOpus, affVorbis, affWAV, affRF64, affAIFF, affAIFC, affDFF, affDSF, affOptimFrog, affMusePack

Download link in the first post.
« Last Edit: 4 Jan '15 - 19:59 by 3delite »