Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 899653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:15:17+00:00 2026-05-15T15:15:17+00:00

What follows is an initializer method. It creates a Movie structure from a file,

  • 0

What follows is an initializer method. It creates a Movie structure from a file, with an eye to extracting the raw pixels for processing, as per Apple QA1443. This is then wrapped in a QTMovie – sourceMovie = [QTMovie movieWithQuickTimeMovie: ...] – for convenience.

After initializing such an object, the second method is called, and we attempt to use sourceMovie. However, it turns out that any attempt to access sourceMovie here results in EXC_BAD_ACCESS For instance, NSLog(@"%@", sourceMovie) is impossible. The movie appears to have been deallocated, although it is not clear why.

Furthermore, in this second method, the usual methods to obtain a CVPixelBufferRef do not properly function: QTVisualContextIsNewImageAvailable seems always to return NO, and QTVisualContextCopyImageForTime always gives you an imageBuffer pointing at 0x00. (I guess this is not surprising if the QTMovie, Movie or visualContext are somehow being deallocated.)

The question then is, why is sourceMovie inaccessible from the second method? Is it being deallocated as it seems? If so, why?

And now the code, and sorry in advance for the length.

// From the .h, we have the following inst var declarations:
Movie                    myMovie;
QTMovie                  *sourceMovie;
QTVisualContextRef        visualContext;
CVPixelBufferRef         imageBuffer;
pixels_xy                sourceSize;
MovieAnalyzer            *analyzer;

// And now to the @implementation...

-(id)initWithFileString:(NSString *)file {
    if (self = [super init]) {
        NSError *e;

        // Bit of a hack - get the movie size using temporary QTMovie.
        sourceMovie = [QTMovie movieWithFile:file error:&e];
        if (e) {
            [self release];
            NSLog(@"Could not open movie.");
            return nil;
        }

        NSSize movieSize = [[sourceMovie posterImage] size];
        CGRect bounds = CGRectMake(0, 0, movieSize.width, movieSize.height);

        // Save the size in pixels.
        sourceSize.x = (int)movieSize.width, sourceSize.y = (int)movieSize.height;

        CFStringRef movieLocation = (CFStringRef) file;

        // Get a QT Visual Context, and create a movie inialized to use it for output.
        visualContext = NULL;
        OSStatus status = CreatePixelBufferContext(k32ARGBPixelFormat, &bounds, &visualContext);
        if (noErr != status && NULL == visualContext) {
            [self release];
            NSLog(@"Problem initializing QT Visual Context.");
            return nil;
        }

        /*** Instantiate the Movie ***/
        myMovie = NULL;
        Boolean trueValue = true;
        QTNewMoviePropertyElement newMovieProperties[3] = {0};

        // Setup movie location
        newMovieProperties[0].propClass = kQTPropertyClass_DataLocation;
        newMovieProperties[0].propID = kQTDataLocationPropertyID_CFStringPosixPath;
        newMovieProperties[0].propValueSize = sizeof(CFStringRef);
        newMovieProperties[0].propValueAddress = &movieLocation;

        // Assign the visual context - could also be NULL
        newMovieProperties[1].propClass = kQTPropertyClass_Context;
        newMovieProperties[1].propID = kQTContextPropertyID_VisualContext;
        newMovieProperties[1].propValueSize = sizeof(visualContext);
        newMovieProperties[1].propValueAddress = &visualContext;

        // Make the movie active
        newMovieProperties[2].propClass = kQTPropertyClass_NewMovieProperty;
        newMovieProperties[2].propID = kQTNewMoviePropertyID_Active;
        newMovieProperties[2].propValueSize = sizeof(trueValue);
        newMovieProperties[2].propValueAddress = &trueValue;

        status = NewMovieFromProperties(3, newMovieProperties, 0, NULL, &myMovie);
        if (status != noErr || myMovie == NULL) {
            NSLog(@"Problem initializing theMovie"); // problem
            [self release];
            return nil;
        }

        // Create a new QTMovie with the Movie as its backing object
        sourceMovie = [QTMovie movieWithQuickTimeMovie:myMovie disposeWhenDone:NO error:&e];
        if (e) {
            NSLog(@"Could not initialize QTMovie from Movie.");
            [self release];
            return nil;
        }

        [sourceMovie stepForward];
        analyzer = [[MovieAnalyzer alloc] initWithColorString:"BGRA" andSourceSize:sourceSize];
    }
    return self;
}


-(NSImage*) supplyCalibrationImage {
    NSLog(@"%x", &sourceMovie);

    [sourceMovie stepForward];    // This fails!
    ....
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:15:18+00:00Added an answer on May 15, 2026 at 3:15 pm

    [QTMovie movieWithQuickTimeMovie:disposeWhenDone:error:] is returning an autoreleased movie. If you want it to stick around past that one method, you need to retain it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.