Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Merging a sprite track and video/audio tracks together



Hi all,

I've successfully created the following:

1. A video/audio track - using the sequence grabber. (the filename for this is stored in 'movieFileName')
2. A sprite track, the same size as that in (1). As far as I know, I don't set the background color of the track. It appears black, but I can see the mouse cursor (which is what I'm capturing) moving about on the .mov if I play it in quicktime. (the filename for this is stored in [spriteTrack movieFileName])


Both tracks are of the same length (roughly), and use the same timescale.

I'm attempting to merge these together using the code helpfully provided by Tim Monroe.
The problem I'm seeing is that the merge results in a movie that contains just the sprite track (even though the properties suggest that sound and the H264 video are present). It's as though there really is a background in the sprite track, and it's covering the video track.


The sprite track is created using:
track = NewMovieTrack(theMovie, width, height, kNoVolume);
media = NewTrackMedia(track, SpriteMediaType, kVideoTimeScale, NULL, 0);


and I don't set any properties on the QTAtomContainers that relate to background colour.
If I remove the code that creates the second track (NewMovieTrack, NewTrackMedia etc), then the resulting movie contains the correct video/audio.


I've also just noticed that the resulting movie actually just points to the temporary movie files movieFileName and spriteTrack movieFileName]... but I won't complicate the question by asking how I actually manage to shift the data into a single movie file ;-)

I've tried various versions on the theme below - such as creating the original movie using a reference to the captured video/audio movie, and then adding a single segment for the sprite track - or using the NewMovieTrack/NewTrackMedia (which is the method being used below) to insert a new track. Both produce the same result.

Can anyone give me some pointers here?

- (void) mergeVideoAndSpriteTrack {
	NSFileManager *mgr = [NSFileManager defaultManager];
	movieFileName = [[mgr fileOnDesktop:@"iShowU-Capture"] retain];

NSError *error = nil;
QTMovie *movie = [QTMovie movieWithAttributes:nil error:&error];
if(error) {
NSLog(@"error creating new movie %@", error);
}

[movie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieEditableAttribute];



error = nil;
QTMovie *screen = [QTMovie movieWithFile:tempFileName error:&error];
if(error) {
NSLog(@"Error opening sprite movie %@", error);
}
QTTimeRange screenRange = QTMakeTimeRange(QTZeroTime, [screen duration]);
[movie insertSegmentOfMovie:screen timeRange:screenRange atTime:QTZeroTime];

error = nil;
QTMovie *cursor = [QTMovie movieWithFile:[spriteTrack movieFileName] error:&error];
if(error) {
NSLog(@"Error opening sprite movie %@", error);
}
QTTimeRange spriteRange = QTMakeTimeRange(QTZeroTime, [cursor duration]);

NSSize size = [[window sampler] captureRect].size;
Track dstTrack = NewMovieTrack([movie quickTimeMovie], (short) size.width << 16, (short)size.height << 16, (short)(1 * 256.0));
Media dstMedia = NewTrackMedia(dstTrack, SpriteMediaType, kVideoTimeScale, NULL, 0);
if (dstTrack && dstMedia) {
QTTrack *dstQTTrack = [QTTrack trackWithQuickTimeTrack:dstTrack error:nil];
if (dstQTTrack) {
[dstQTTrack insertSegmentOfTrack:[[cursor tracks] objectAtIndex:0] timeRange:spriteRange atTime:QTZeroTime];
}
}

[movie writeToFile:movieFileName withAttributes:nil];
[movie updateMovieFile];



--- Neil Clayton



_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.