Skip to content

Commit

Permalink
- fix for black frames as per BradLarson#1255 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakinaeem committed Dec 26, 2014
1 parent ff357d4 commit 98bff65
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions framework/Source/iOS/GPUImageMovieWriter.m
Expand Up @@ -3,6 +3,7 @@
#import "GPUImageContext.h"
#import "GLProgram.h"
#import "GPUImageFilter.h"
static BOOL allowWriteAudio = NO;

NSString *const kGPUImageColorSwizzlingFragmentShaderString = SHADER_STRING
(
Expand Down Expand Up @@ -266,6 +267,7 @@ - (void)setEncodingLiveVideo:(BOOL) value

- (void)startRecording;
{
allowWriteAudio = NO;
alreadyFinishedRecording = NO;
startTime = kCMTimeInvalid;
runSynchronouslyOnContextQueue(_movieWriterContext, ^{
Expand Down Expand Up @@ -362,6 +364,10 @@ - (void)finishRecordingWithCompletionHandler:(void (^)(void))handler;

- (void)processAudioBuffer:(CMSampleBufferRef)audioBuffer;
{

if (!allowWriteAudio) {
return;
}
if (!isRecording)
{
return;
Expand Down Expand Up @@ -437,6 +443,8 @@ - (void)processAudioBuffer:(CMSampleBufferRef)audioBuffer;
{
if (![assetWriterAudioInput appendSampleBuffer:audioBuffer])
NSLog(@"Problem appending audio buffer at time: %@", CFBridgingRelease(CMTimeCopyDescription(kCFAllocatorDefault, currentSampleTime)));
allowWriteAudio = YES;

}
else
{
Expand Down

6 comments on commit 98bff65

@yumincode
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for solving my question...

@yumincode
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when i add your code to .m there is no audio in my video,can you help me ?

@zakinaeem
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally depends on what you're trying to achieve and how you've structured your code. Happy to help if you post your code through and give a bit of background.

@mingyue1991
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great solution! Why BradLarson didn't merge

@mingyue1991
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e~~,it can avoid the black frame at the beginning, but the black frame at the end still occur sometimes

@Water95
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when i add your code to .m there is no audio in my video,can you help me ?

Please sign in to comment.