MP4Modify fails to add metadata on an empty mp4-file

46 views
Skip to first unread message

Holger Jansen

unread,
Dec 13, 2011, 4:00:14 AM12/13/11
to mp4v2
Hi,

I generated a clean mp4-file using ffmpeg. I wanted to add some iTunes
metadata using MP4Modify and the generic interface. I used the
MP4ItmfAddItem() function as described in the generic example, but it
always returns FALSE on this file. If I use files already containing
some iTunes tags, it works fine.

I debugged the MP4ItmfAddItem() and found the line, where it fails. It
is in generic.cpp/genericAddItem. The atom "mood.udta.meta.ilist" is
missing. Is there any solution for this problem, e.g. some way to add
the missing atom before?

Thanks for some help

Holger

bool
genericAddItem( MP4File& file, const MP4ItmfItem* item )
{
MP4Atom* ilst = file.FindAtom( "moov.udta.meta.ilst" ); // returns
null
if( !ilst )
return false;

MP4ItemAtom& itemAtom = *(MP4ItemAtom*)MP4Atom::CreateAtom( ilst,
item->code );
ilst->AddChildAtom( &itemAtom );

return __itemModelToAtom( *item, itemAtom );
}

Jeremy Noring

unread,
Dec 19, 2011, 10:14:50 PM12/19/11
to mp4v2

Does your API call:

http://mp4v2.googlecode.com/svn/doc/trunk/api/group__mp4__itmf__generic.html#ga93bb2f5a0bc2e09c1bb8a430139daff4

In general the workflow for the ITMF stuff, to add a new item, is:

MP4ItmfItemAlloc()
MP4ItmfAddItem()
MP4ItmfItemFree()

...is this what you're doing in the file?

If not, I'd suggest filing a bug and affixing the file (or one that
reproduces the issue) to the bug, and I can see if I can figure out
how to make it work.

Holger

unread,
Dec 20, 2011, 4:46:39 AM12/20/11
to mp4v2
Hello Jeremy,

yes, I tried it with Alloc,Add and Free. I also tried the other
interface with:

const MP4Tags* tags = MP4TagsAlloc();
MP4TagsFetch( tags, srcFile );
MP4TagsStore( tags, destFile );
MP4TagsFree( tags );
MP4Close( srcFile );
MP4Close( destFile );

This fails also on a mp4-destination file without any tags. My work
around was to set one tag with the deprecated method
MP4SetMetadataCompilation(destFile, 0) because this old routine checks
first, if the atom "moov..." exists. If not it creates a new one. This
works, but it's not the best solution.

I tested with an mp4-File build by ffmpeg. ffmpeg doesn't create any
tags. Handbreak and other tools write some data into the coded files,
so the error can't be reproduced by such files. I will open a bug
report on the issue with my test file attached.

Thanks

Holger

> http://mp4v2.googlecode.com/svn/doc/trunk/api/group__mp4__itmf__gener...

Reply all
Reply to author
Forward
0 new messages