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

  • SEARCH
  • Home
  • 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 6855783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:48:05+00:00 2026-05-27T01:48:05+00:00

I have a video app that does both a live preview as well as

  • 0

I have a video app that does both a live preview as well as a still image capture while the preview is running. I am using 4 textures that are pre-generated when the app loads. I am accessing the textures across three threads.

In order to make the live preview work, I had to make a Sharegroup (see below) so that the captureOutput method could store a result in a framebuffer called FBO_OUT. Then, in order to display to the screen I needed to access FBO_OUT for the call to presentRenderbuffer. If I didn’t use the Sharegroup, I just got a bunch of gibberish.

CAEAGLLayer* eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
                                kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
                                nil];
oglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
offscreenContext = [[EAGLContext alloc] initWithAPI:[oglContext API] sharegroup:oglContext.sharegroup];
if (!oglContext || ![EAGLContext setCurrentContext:oglContext]) {
    NSLog(@"Problem with OpenGL context.");
    [self release];

    return nil;
}

Periodically, inside the captureOutput I need to call this code:

#define SHAREGROUP_CONTEXT [[[appDelegate mainViewController] oglView] offscreenContext]

 if ([EAGLContext currentContext] != SHAREGROUP_CONTEXT) {
     NSLog(@"setting context");
     glFlush();
     [EAGLContext setCurrentContext:SHAREGROUP_CONTEXT];
 }

 @synchronized(SHAREGROUP_CONTEXT)
 {
    /* process pixels */
 }

 glFlush();  // at end of method

This works fine, the problem, is that I’m now trying to do the same thing after taking a Still Image (while the preview is still running) via captureStillImageAsynchronouslyFromConnection block, however I am getting gibberish again even though I’ve tried doing this:

AVCaptureConnection *sic = [AVCamUtilities connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]];

[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:sic
                                                     completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) 
 {

     @synchronized(SHAREGROUP_CONTEXT)
     {

         /* generate new textures to process the imageDataSampleBuffer and cry */
     }

This seems to be a problem with contexts and threading.

  • 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-27T01:48:06+00:00Added an answer on May 27, 2026 at 1:48 am

    I’ve found the answer. You need to make sure the @synchronized block is in both methods. This took me so long to find because something very strange was happening with my shaders. One of the filenames was lowercase on disk when XCode thought they were all uppercase. This made the shader work in the live preview but gave me a white screen in the still image capture portion. No idea why.

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

Sidebar

Related Questions

I have an app that streams video from the net and plays it using
I have a UserControl that does some cool video capture stuff. Now I slapped
Well i have an adobe air app that captures screen and saves image on
I have a flex 3 app that uses netstream and a video object to
I've seen a few sites that have a flash app which takes video from
I have three camera-based apps (that take still pictures) in the app-store and have
I'm hoping to make an app that streams live video that has a view
From Apple: 9.4 We found that your app does not use the HTTP Live
I have an app that loads while a 2 second movie plays. Currently the
i'm trying to create an app that allows video recording. i know that using

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.