I'm trying to make a QTMovie with picture in picture. I have two movies, one that is a video from a file, and one recorded with a camera.
I want the camera movie to show up above the other video and be slightly transparent. I can position the camera movie over the other video fine using a qttrack, but I don't know how to change the transparency of the qttrack on the video.
Is this possible using QTKit?
Here is an example of my code right now
QTTimeRange fullMovieDuration = QTMakeTimeRange(QTZeroTime, [mCameraMovie duration]);
QTTime startTime = QTMakeTime(0, [mCameraMovie currentTime].timeScale);
QTTrack *cameraTrack = [[mCameraMovie tracks] objectAtIndex:0];
NSRect newCameraRect = NSMakeRect(100, 100, 320, 240);
[cameraTrack setAttribute:[NSValue valueWithRect:newCameraRect] forKey:QTTrackBoundsAttribute];
[mMovie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieEditableAttribute];
[mMovie insertSegmentOfTrack:cameraTrack timeRange:fullMovieDuration atTime:startTime];
[ibMovieView setMovie:mMovie];
I was able to do it using Quicktime.
Here's a category that got it done.
Header
#import <QTKit/QTKit.h>
@interface QTTrack (QTTrack_Opacity)
-(void)setOpacity:(float)opacity;
@end
Source File
@implementation QTTrack (QTTrack_Opacity)
-(void)setOpacity:(float)opacity
{
MediaHandler mh = GetMediaHandler([[self media] quickTimeMedia]);
RGBColor color = { (int)(opacity*255) << 8, (int)(opacity*255) << 8, (int)(opacity*255) << 8};
MediaSetGraphicsMode(mh, graphicsModeStraightAlphaBlend, &color);
}
@end