Re: Creating movie on background thread
Re: Creating movie on background thread
- Subject: Re: Creating movie on background thread
- From: James Chen <email@hidden>
- Date: Tue, 02 Sep 2008 12:59:52 +0800
- Thread-topic: Creating movie on background thread
Hi,
Despite thread issue, I think there's a memory management issue which is
mentioned in Apple's document,"Memory Management Programming Guide for
Cocoa"(http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
Concepts/AutoreleasePools.html).
"If you write a loop that creates many temporary objects, you may create an
autorelease pool inside the loop to dispose of those objects before the next
iteration. This can help reduce the maximum memory footprint of the
application."
Hope this help.
Best Regards,
James Chen
Presentation Product Division
TEL: +886-2-2226-3630ext 8538
FAX: +886-2-2226-8751
Mailto: email@hidden
http://www.avermedia.com
AVerMedia Information, Inc.
簡報產品事業單位: 陳銘崧
圓展科技股份有限公司
This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive messages for the
addressee), you cannot use, copy or disclose to any third party or any
information contained in the message. If you have received the message in
error, please advise the sender by reply e-mail and delete the message.
Nothing in this message should be interpreted as a digital or electronic
signature that can be used to authenticate a contract or to other legal
document. Thank you very much.
> From: Roger Herikstad <email@hidden>
> Date: Tue, 2 Sep 2008 12:50:19 +0800
> To: Cocoa <email@hidden>, Quicktime QuickTIme
> <email@hidden>
> Subject: Creating movie on background thread
>
> Hi lists,
> Sorry for the cross-posting, but I thought my issue to relevant for
> both lists. I need to create an image sequence of some plots from a
> graphing application that i'm writing, and I would like to be able to
> do this on a background thread. Basically, I ask my app to plot some
> signals on screen (~1000 individual signals) and once I'm happy with
> how the signals look, I'd like to create an image sequence so that if
> I want to look at those signals again, I have only to load up the
> movie instead of plotting them again. I'm using an NSOperation object
> for constructing my movie. The relevant code is
>
> - (void)createMovieInRect:(NSRect)aRect
> {
> NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
> NSError *error = [NSError errorWithDomain: @"thisDomain" code: 1
> userInfo: nil];
> QTMovie *movie = [[QTMovie alloc] initToWritableFile: output_file
> error: &error];
> //QTMovie *movie = [QTMovie movie];
>
> //NSImage *image = NULL;
> QTTime duration = QTMakeTime(1,10);
>
> NSDictionary *attribs = nil;
> attribs = [NSDictionary dictionaryWithObjectsAndKeys:@"avc1",
> QTAddImageCodecType,
> [NSNumber numberWithLong:codecHighQuality],
> QTAddImageCodecQuality,
> nil];
> QTTime dur;
> BOOL success = NO;
> int i;
> NSLog([NSString stringWithFormat: @"Creating movie of %d
> frames\n",num_waves ]);
>
> for(i=0;i< num_waves;i++)
> {
> [_image release];
> _image = NULL;
> [self setdrawWaves: [NSIndexSet indexSetWithIndex: i]];
> [self drawInRect: aRect];
> [movie addImage: [self image] forDuration: duration
> withAttributes: attribs];
> success = [movie updateMovieFile];
> CGContextRestoreGState(context);
>
> }
>
> [movie release];
> [_image release];
> [pool release];
> }
>
> When I create my operation object and add it to the queue, the process
> of creating the movie seems exceedingly slow, 1 hour+ to create a
> movie consisting of 1,000 images. My question is, is there something
> in the QTKit that prevents it from working properly on a background
> thread? There are probably other issues with my code that could be
> optimised, but I just wanted to rule out multi-threading problems.
> Thanks!
>
> ~ Roger
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden