Memory Pressure Crash #1634

Open
imran4125 opened this Issue Jun 23, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@imran4125

Hi Brad,
i am trying to play 3 videos on a gpuimageview and also applying filters to 2 of the videos and trying to record the result by a writer but after 3-5 few seconds it starts giving memory warning and eventually it crashes in a couple of more seconds...what could the problem be? as its been more then a week i am stuck on it.

@imran4125

This comment has been minimized.

Show comment
Hide comment
@imran4125

imran4125 Jun 23, 2014

This is my code

NSURL *urlA = [[NSBundle mainBundle] URLForResource:@"abc" withExtension:@"mp4"];
self.gpuMovieA = [[GPUImageMovie alloc] initWithURL:urlA];


NSURL *urlB = [[NSBundle mainBundle] URLForResource:@"acb" withExtension:@"mp4"];
self.gpuMovieFX = [[GPUImageMovie alloc] initWithURL:urlB];

NSURL *urlU = [[NSBundle mainBundle] URLForResource:@"cab" withExtension:@"m4v"];
self.gpuMovieUser = [[GPUImageMovie alloc] initWithURL:urlU];

// Filter the effect, masking the opacity
self.maskFilter = [[GPUImageMaskFilter alloc] init];
[self.maskFilter forceProcessingAtSizeRespectingAspectRatio:self.movieView.frame.size];

[self.gpuMovieA addTarget:self.maskFilter];
[self.gpuMovieFX addTarget:self.maskFilter];


// Blend with the third movie
self.overlayFilter = [[GPUImageNormalBlendFilter alloc] init];
[self.overlayFilter forceProcessingAtSizeRespectingAspectRatio:self.movieView.frame.size];
 [self.gpuMovieUser addTarget:self.overlayFilter];
 [self.maskFilter addTarget:self.overlayFilter];

[self.maskFilter addTarget:self.movieView];
[self.movieView setBackgroundColorRed:0 green:0 blue:0 alpha:0];

//setup writer

NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/output111.mp4"];
unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
NSURL* convertedVideoPath = [[NSURL fileURLWithPath:pathToMovie] retain];

self.movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:convertedVideoPath
                                                            size:CGSizeMake(640.0, 480.0)];
[self.overlayFilter addTarget:self.movieWriter];
self.movieWriter.shouldPassthroughAudio = YES;
self.gpuMovieA.audioEncodingTarget = nil;
[self.gpuMovieA enableSynchronizedEncodingUsingMovieWriter:self.movieWriter];

[self.movieWriter startRecording];
[self.gpuMovieA startProcessing];
[self.gpuMovieFX startProcessing];
// [self.gpuMovieUser startProcessing];

[self.movieWriter setCompletionBlock:^{
    self.gpuMovieA.audioEncodingTarget = nil;
    [self.gpuMovieFX endProcessing];
    [self.gpuMovieA endProcessing];
    //[self.gpuMovieUser endProcessing];
    [self.movieWriter finishRecording];
    dispatch_async(dispatch_get_main_queue(), ^{
    });

This is my code

NSURL *urlA = [[NSBundle mainBundle] URLForResource:@"abc" withExtension:@"mp4"];
self.gpuMovieA = [[GPUImageMovie alloc] initWithURL:urlA];


NSURL *urlB = [[NSBundle mainBundle] URLForResource:@"acb" withExtension:@"mp4"];
self.gpuMovieFX = [[GPUImageMovie alloc] initWithURL:urlB];

NSURL *urlU = [[NSBundle mainBundle] URLForResource:@"cab" withExtension:@"m4v"];
self.gpuMovieUser = [[GPUImageMovie alloc] initWithURL:urlU];

// Filter the effect, masking the opacity
self.maskFilter = [[GPUImageMaskFilter alloc] init];
[self.maskFilter forceProcessingAtSizeRespectingAspectRatio:self.movieView.frame.size];

[self.gpuMovieA addTarget:self.maskFilter];
[self.gpuMovieFX addTarget:self.maskFilter];


// Blend with the third movie
self.overlayFilter = [[GPUImageNormalBlendFilter alloc] init];
[self.overlayFilter forceProcessingAtSizeRespectingAspectRatio:self.movieView.frame.size];
 [self.gpuMovieUser addTarget:self.overlayFilter];
 [self.maskFilter addTarget:self.overlayFilter];

[self.maskFilter addTarget:self.movieView];
[self.movieView setBackgroundColorRed:0 green:0 blue:0 alpha:0];

//setup writer

NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/output111.mp4"];
unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
NSURL* convertedVideoPath = [[NSURL fileURLWithPath:pathToMovie] retain];

self.movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:convertedVideoPath
                                                            size:CGSizeMake(640.0, 480.0)];
[self.overlayFilter addTarget:self.movieWriter];
self.movieWriter.shouldPassthroughAudio = YES;
self.gpuMovieA.audioEncodingTarget = nil;
[self.gpuMovieA enableSynchronizedEncodingUsingMovieWriter:self.movieWriter];

[self.movieWriter startRecording];
[self.gpuMovieA startProcessing];
[self.gpuMovieFX startProcessing];
// [self.gpuMovieUser startProcessing];

[self.movieWriter setCompletionBlock:^{
    self.gpuMovieA.audioEncodingTarget = nil;
    [self.gpuMovieFX endProcessing];
    [self.gpuMovieA endProcessing];
    //[self.gpuMovieUser endProcessing];
    [self.movieWriter finishRecording];
    dispatch_async(dispatch_get_main_queue(), ^{
    });
@yderidde

This comment has been minimized.

Show comment
Hide comment
@yderidde

yderidde Dec 17, 2014

Hey @imran4125 were you able to fix this ? I'm running into the same problem...

Hey @imran4125 were you able to fix this ? I'm running into the same problem...

@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