Skip to content

Instantly share code, notes, and snippets.

@thepatrick
Created May 31, 2009 02:07
Show Gist options
  • Save thepatrick/120716 to your computer and use it in GitHub Desktop.
Save thepatrick/120716 to your computer and use it in GitHub Desktop.
-(IBAction)magic:(id)sender {
NSError *err = nil;
NSLog(@"Loading nothing movie...");
NSURL *nothing = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"nothing" ofType:@"mov"]];
QTMovie *mMovie = [QTMovie movieWithURL:nothing error:&err];
if(err != nil) {
NSLog(@"Failed to create qtmovie: %@", err);
return;
}
[mMovie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieEditableAttribute];
NSLog(@"Loading movie to be wrapped...");
NSURL *working = [NSURL fileURLWithPath:@"/Users/patrick/Desktop/test/TestMovie.avi"];
QTMovie *wMovie = [QTMovie movieWithURL:working error:&err];
if(err != nil) {
NSLog(@"Failed to create working qtmovie: %@", err);
return;
}
NSLog(@"Inserting...");
[mMovie insertSegmentOfMovie:wMovie timeRange:QTMakeTimeRange(QTZeroTime, [wMovie duration]) atTime:QTZeroTime];
NSLog(@"Flattening it...");
NSString *filePath = @"/Users/patrick/Desktop/test/TestMovie.mov";
// create a new movie file and flatten the movie to the file
BOOL success = [mMovie writeToFile:filePath withAttributes:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
forKey:QTMovieFlatten]];
if(!success)
NSLog(@"Movie flattening failed.");
NSLog(@"Done.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment