Question

I need to write some code that will let me query a m4a file and extract the chapter information out. Including:

  • chapter name
  • chapter start time
  • chapter artwork

I did some quick searching and it seems this is viewed as proprietary information by Apple? I found some discussions, but most were from 2005. Also there have been some similar questions on here, but more for CREATING m4a files with chapters, not querying.

Is this just something I have to DIY, cause there isn't a nice apple API for me to use? Or am I missing something obvious?

Also, ideally I need whatever technique I end up using to work on the iPhone.

Was it helpful?

Solution

The metadata tags system is Apple-proprietary. To work with the tags, you have to (sigh) reverse-engineer it or work with a library that has already done this.

I found the following links, but honestly it seems like you will have to pull out the hex editor.

Binary format info (basic spec for generic tags)

Perl library for working with M4A files.

OTHER TIPS

Turns out this is much simpler than talked about here in the "answers". Not sure if this works on the iPhone, but I just tested it in a command line app:

QTMovie* movie = [QTMovie movieWithFile:@"filename.m4a" error:nil];

NSInteger numChapters = [movie chapterCount];
NSLog(@"Number of Chapters: %d", numChapters);

NSArray* chapterArray = [movie chapters];
for ( NSDictionary* chapDict in chapterArray )
{
    NSLog(@"%@", [chapDict objectForKey:@"QTMovieChapterName"] );
}

Easy as pie. DOH!

this library should solve your needs, but is not runnable on iphone without jailbreaking I would think. http://wmptagext.sourceforge.net/

oops if you need it to work on iphone there is probably an apple api to get this info. /me looks it sounds like you need to play around with the ipodlibrary library....

http://developer.apple.com/iphone/library/documentation/Audio/Conceptual/iPodLibraryAccess_Guide/UsingTheiPodLibrary/UsingTheiPodLibrary.html#//apple_ref/doc/uid/TP40008765-CH101-SW1

If the files in question live in the iPod library, maybe you can get your information via the MPMediaLibrary query interface (3.0 upward).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top