New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chroma Key Blend filter with two videos and a movie writer makes OpenGL queue crash #773

Open
pbernery opened this Issue Jan 21, 2013 · 7 comments

Comments

Projects
None yet
4 participants
@pbernery

Hi,

I use GPUImage to blend two videos (one of them as a green background) and display the result on an iPhone screen (with a live video or a video from a file).
It works pretty well until I add a movie writer to record the result.

Here is the code:

    self.movie = [[GPUImageMovie alloc] initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"source" ofType:@"mov"]]];
    self.greenMovie = [[GPUImageMovie alloc] initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"greenscreen" ofType:@"mp4"]]];

    GPUImageChromaKeyBlendFilter *filter = [[GPUImageChromaKeyBlendFilter alloc] init];
    [self.greenMovie addTarget:filter];
    [self.movie addTarget:filter];

    GPUImageView *filterView = (GPUImageView *)self.view;
    [filter addTarget:filterView];

    self.writeURL = [NSURL fileURLWithPath:[@"~/Library/Caches/movie.mov" stringByExpandingTildeInPath]];
    unlink([[self.writeURL absoluteString] UTF8String]);
    self.writer = [[GPUImageMovieWriter alloc] initWithMovieURL:self.writeURL size:CGSizeMake(640, 320)];
    [self.movie enableSynchronizedEncodingUsingMovieWriter:self.writer];
    [filter addTarget:self.writer];

    [self.writer startRecording];

    [self.greenMovie startProcessing];
    [self.movie startProcessing];

The stack of the queue that crashed after adding the writer:

Thread 9, Queue : com.sunsetlakesoftware.GPUImage.openGLESContextQueue
#0  0x3336e350 in __pthread_kill () <-- crash point
#1  0x367d7122 in pthread_kill ()
#2  0x36813972 in abort ()
#3  0x002f55d8 in dy_abort ()
#4  0x00194e76 in wrapper_cache_texture_binding ()

Any idea or clue to get more information about the crash?

@BradLarson

This comment has been minimized.

Show comment
Hide comment
@BradLarson

BradLarson Jan 21, 2013

Owner

What class of device is this, and what iOS version?

It's possibly a memory exhaustion issue. How big are the videos you're trying to blend here?

Owner

BradLarson commented Jan 21, 2013

What class of device is this, and what iOS version?

It's possibly a memory exhaustion issue. How big are the videos you're trying to blend here?

@pbernery

This comment has been minimized.

Show comment
Hide comment
@pbernery

pbernery Jan 21, 2013

This is tested on an iPhone 4, iOS 6.0.1

I did'nt thought about a memory exhaustion issue. I try to blend two videos of 1280x720 pixels. I also tried with one of 1280x720 and the second one of 640x320.

This is tested on an iPhone 4, iOS 6.0.1

I did'nt thought about a memory exhaustion issue. I try to blend two videos of 1280x720 pixels. I also tried with one of 1280x720 and the second one of 640x320.

@pbernery

This comment has been minimized.

Show comment
Hide comment
@pbernery

pbernery Jan 21, 2013

I am not sure this is related to memory: I also have another part of my code that does almost the same thing except that the source video is the camera of the iPhone. Everything works well too unless I enable the recording of the result.

In that case, I capture a video of 960x540 and the blended video is of 640x360. I display the video on screen.

I am not sure this is related to memory: I also have another part of my code that does almost the same thing except that the source video is the camera of the iPhone. Everything works well too unless I enable the recording of the result.

In that case, I capture a video of 960x540 and the blended video is of 640x360. I display the video on screen.

@BradLarson

This comment has been minimized.

Show comment
Hide comment
@BradLarson

BradLarson Jan 21, 2013

Owner

There is a possibility that this is due to out-of-order timestamps. With two movie sources being blended, sometimes both timestamps from the two movies get passed into the movie writer, confusing it. That shouldn't cause a crash, just stuttering and perhaps an early termination of the movie. Still, its possible that it could be getting into an unstable state if that occurs. The two-input filter superclass has a bug in it regarding this, but I don't have a clean fix right now.

Owner

BradLarson commented Jan 21, 2013

There is a possibility that this is due to out-of-order timestamps. With two movie sources being blended, sometimes both timestamps from the two movies get passed into the movie writer, confusing it. That shouldn't cause a crash, just stuttering and perhaps an early termination of the movie. Still, its possible that it could be getting into an unstable state if that occurs. The two-input filter superclass has a bug in it regarding this, but I don't have a clean fix right now.

@toohtik

This comment has been minimized.

Show comment
Hide comment
@toohtik

toohtik Aug 16, 2013

Hi Brad! According to your last post. Please suggest us how to fix timestamps ordering. Thank you

toohtik commented Aug 16, 2013

Hi Brad! According to your last post. Please suggest us how to fix timestamps ordering. Thank you

@lalubema

This comment has been minimized.

Show comment
Hide comment
@lalubema

lalubema Aug 23, 2013

@pbernery Have you solved this? It worked for u?

@pbernery Have you solved this? It worked for u?

@pbernery

This comment has been minimized.

Show comment
Hide comment
@pbernery

pbernery Aug 24, 2013

@lalubema I cannot really remember but I don't think so. I think I disabled the write in the end. I stopped working on this several month ago so...

@lalubema I cannot really remember but I don't think so. I think I disabled the write in the end. I stopped working on this several month ago so...

@tuo tuo referenced this issue Feb 5, 2015

Closed

Fix movie writer #1913

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment