making iPod-compatible movies from NSImage arrays
making iPod-compatible movies from NSImage arrays
- Subject: making iPod-compatible movies from NSImage arrays
- From: Brad Keyes <email@hidden>
- Date: Sun, 12 Feb 2006 10:47:12 +1100
I need to create a movie, using a series of screenshots from my
application, that I can show on a 5G iPod.
I'm trying to use the code in CocoaCreateMovie and QTKitCreateMovie
(example projects) as a base for doing this. Basically, those two
projects allow you to iterate through an array of images, adding each
one as a frame into the movie, as follows (excerpted from
QTMovieExtensions.m in project QTKitCreateMovie):
myDict = [NSDictionary dictionaryWithObjectsAndKeys:@"mp4v",
QTAddImageCodecType,
[NSNumber numberWithLong:codecLowQuality],
QTAddImageCodecQuality,
nil];
....
QTTime curTime = QTMakeTime(30, 600);
....
//for each URL containing an image:
NSImage *anImage = [[NSImage alloc] initWithContentsOfURL:fileURL];
[self addImage:anImage
forDuration:curTime
withAttributes:myDict];
[anImage release];
(CocoaCreateMovie works quite similarly if I understand the code correctly.)
Later, when you've added all the images into the movie, another method
flattens the movie to a given path.
So far, so good - I give the program one NSImage at a time, of size
320x240, which I captured from my other application. It creates and
writes out a movie. The movie plays properly in QuickTime and iTunes.
It appears (to me) to satisfy all the requirements for playing on the
video iPod too. QuickTime's Movie Info window says it's an MPEG-4
Video, 320x240, millions of colors. The data rate is usually below 800
kbps, especially if I used codecLowQuality or codecMinQuality in
myDict, which is well within the rate the iPod supports. It's only 20
FPS. The resolution is the iPod's native resolution. And iTunes even
automatically syncs the movie onto my iPod, so that implies that
iTunes thinks it can play it (doesn't it?).
But when I try to play it on the pod, the screen just goes black for
the duration. (Before I upgraded to the 1.1 software, it was even
worse - the screen would go black for just a second, then return to
the movies menu but be frozen - unresponsive - for a while.)
What am I doing wrong? (Possibly I'm misunderstanding something basic
about codecs. Please be gentle.)
Further info if it helps:
- My iPod is a 30 gig video, software version 1.1
- I tried changing @"mp4v" to @"avc1" and that rendered out H264
movies, which also seemed to meet all the criteria for iPod
playability, but they didn't even sync onto the iPod (from iTunes).
- I tried changing the extension from .mov to .mp4 and .m4v, a "hack"
suggested on the QuickTime users lists, but that didn't help.
- Passing my movies through iSquint, podner, or even through the
ThreadsExportMovie sample project, creates an exported file which
works fine on the iPod, even if (as far as can tell) I didn't change
any of the settings of the movie when exporting it. This is not a
solution I can use long term, though. (But I'll gladly
incorporate/adopt code from the ThreadsExportMovie project if someone
knows which part of it is doing what I need.)
- In my experiments using ThreadsExportMovie, the only settings that
*don't* work on my pod, even if iTunes syncs the movie onto it, are
where I set the key frame rate to "Every frame". Maybe the iPod can't
handle all key frames. But I don't know what key frame rate the
CocoaCreateMovie and QTKitCreateMovie projects are using. I don't know
where in the code, if anywhere, that is being controlled.
- When I use the CocoaCreateMovie project as a base and do the same
steps (mutatis mutandis), it creates movies with the same playback
problem, but with the added wierdness that their Info always claims
they have "Current Resolution" 320x244, but "Normal Resolution"
320x240.
Thanks in advance for any help!!!
Brad Keyes
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden