Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions framework/Source/iOS/GPUImageMovieWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ extern NSString *const kGPUImageColorSwizzlingFragmentShaderString;
- (void)processAudioBuffer:(CMSampleBufferRef)audioBuffer;
- (void)enableSynchronizationCallbacks;

// Addition
- (void)pauseRecording;
- (void)resumeRecording;

@end
29 changes: 28 additions & 1 deletion framework/Source/iOS/GPUImageMovieWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ @interface GPUImageMovieWriter ()

BOOL isRecording;
}
//
@property (nonatomic,strong) NSDate *lastPauseTime;
@property (nonatomic,assign) NSTimeInterval accumulativeInterval;

// Movie recording
- (void)initializeMovieWithOutputSettings:(NSMutableDictionary *)outputSettings;
Expand Down Expand Up @@ -80,6 +83,7 @@ - (id)initWithMovieURL:(NSURL *)newMovieURL size:(CGSize)newSize fileType:(NSStr
return nil;
}

_accumulativeInterval = 0.0;
_shouldInvalidateAudioSampleWhenDone = NO;

self.enabled = YES;
Expand Down Expand Up @@ -692,6 +696,24 @@ - (void)renderAtInternalSizeUsingFramebuffer:(GPUImageFramebuffer *)inputFramebu
glFinish();
}

#pragma mark -
#pragma mark Pause Recording And Resume

- (void)pauseRecording {
isRecording = NO;
//
self.lastPauseTime = [NSDate date];
}

- (void)resumeRecording {
if (self.lastPauseTime) {
NSTimeInterval pass = [[NSDate date] timeIntervalSinceDate:self.lastPauseTime];
self.accumulativeInterval += pass;
}
//
isRecording = YES;
}

#pragma mark -
#pragma mark GPUImageInput protocol

Expand All @@ -702,7 +724,12 @@ - (void)newFrameReadyAtTime:(CMTime)frameTime atIndex:(NSInteger)textureIndex;
[firstInputFramebuffer unlock];
return;
}

//fix the frame time
if (self.accumulativeInterval > 0) {
CMTime offset = CMTimeMake(self.accumulativeInterval*frameTime.timescale, frameTime.timescale);
frameTime = CMTimeSubtract(frameTime, offset);
}
//
if (discont) {
discont = NO;
CMTime current;
Expand Down