@@ -13,7 +13,7 @@ @interface GlimpseAssetWriter()
1313{
1414 CFAbsoluteTime _timeOfFirstFrame;
1515 CFTimeInterval _timestamp;
16- uint64_t _frameRate;
16+ int32_t _frameRate;
1717 uint64_t _frameCount;
1818 dispatch_queue_t _queue;
1919
@@ -40,26 +40,26 @@ - (id)init
4040 if (self)
4141 {
4242 self.size = [[UIScreen mainScreen ] bounds ].size ;
43- self.framesPerSecond = 1 ;
43+ self.framesPerSecond = 24 ;
4444 self.frameBuffer = [[NSMutableArray alloc ] init ];
4545
46- _frameRate = (uint64_t )self.framesPerSecond ;
46+ _frameRate = (int32_t )self.framesPerSecond ;
4747 _queue = dispatch_queue_create ([GlimpseAssetWriterQueueName cStringUsingEncoding: NSUTF8StringEncoding], 0 );
4848 }
4949 return self;
5050}
5151
52- - (NSURL *)fileOutputURL
52+ - (NSURL *)createFileOutputURL
5353{
5454 NSString *documentDirectory = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES ) objectAtIndex: 0 ];
5555 NSTimeInterval timestamp = [[NSDate date ] timeIntervalSince1970 ];
5656 NSString *filename = [NSString stringWithFormat: @" glimpse_%08x .mov" , (int )timestamp];
5757 NSString *path = [NSString stringWithFormat: @" %@ /%@ " , documentDirectory, filename];
5858 NSFileManager *fileManager = [NSFileManager defaultManager ];
59-
59+
6060 if ([fileManager fileExistsAtPath: path])
6161 [fileManager removeItemAtPath: path error: nil ];
62-
62+
6363 NSLog (@" OUTPUT: %@ " , path);
6464 return [NSURL fileURLWithPath: path];
6565}
@@ -69,6 +69,8 @@ - (AVAssetWriter *)writer
6969 if (_writer)
7070 return _writer;
7171
72+ _fileOutputURL = [self createFileOutputURL ];
73+
7274 NSError *error = nil ;
7375 _writer = [[AVAssetWriter alloc ] initWithURL: self .fileOutputURL fileType: AVFileTypeQuickTimeMovie error: &error];
7476 NSAssert (error == nil , error.debugDescription);
@@ -154,10 +156,7 @@ - (void)writeVideoFromImageFrames:(void(^)(NSURL *outputPath))callback
154156 if (self.input .readyForMoreMediaData )
155157 {
156158 i++;
157-
158- CFAbsoluteTime current = CFAbsoluteTimeGetCurrent ();
159- CFTimeInterval elapse = current - _timeOfFirstFrame;
160- CMTime present = CMTimeMake (elapse * 600 , 600 );
159+ CMTime present = CMTimeMake (i , _frameRate);
161160
162161 buffer = [self pixelBufferForImage: image];
163162 BOOL result = [self .adapter appendPixelBuffer: buffer withPresentationTime: present];
0 commit comments