GPUImageMovieWriter.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #import <Foundation/Foundation.h>
  2. #import <AVFoundation/AVFoundation.h>
  3. #import "GPUImageContext.h"
  4. extern NSString *const kGPUImageColorSwizzlingFragmentShaderString;
  5. @protocol GPUImageMovieWriterDelegate <NSObject>
  6. @optional
  7. - (void)movieRecordingCompleted;
  8. - (void)movieRecordingFailedWithError:(NSError*)error;
  9. @end
  10. @interface GPUImageMovieWriter : NSObject <GPUImageInput>
  11. {
  12. CMVideoDimensions videoDimensions;
  13. CMVideoCodecType videoType;
  14. NSURL *movieURL;
  15. NSString *fileType;
  16. AVAssetWriter *assetWriter;
  17. AVAssetWriterInput *assetWriterAudioInput;
  18. AVAssetWriterInput *assetWriterVideoInput;
  19. AVAssetWriterInputPixelBufferAdaptor *assetWriterPixelBufferInput;
  20. dispatch_queue_t movieWritingQueue;
  21. CGSize videoSize;
  22. GPUImageRotationMode inputRotation;
  23. }
  24. @property(readwrite, nonatomic) BOOL hasAudioTrack;
  25. @property(readwrite, nonatomic) BOOL shouldPassthroughAudio;
  26. @property(nonatomic, copy) void(^completionBlock)(void);
  27. @property(nonatomic, copy) void(^failureBlock)(NSError*);
  28. @property(nonatomic, assign) id<GPUImageMovieWriterDelegate> delegate;
  29. @property(readwrite, nonatomic) BOOL encodingLiveVideo;
  30. @property(nonatomic, copy) void(^videoInputReadyCallback)(void);
  31. @property(nonatomic, copy) void(^audioInputReadyCallback)(void);
  32. @property(nonatomic) BOOL enabled;
  33. // Initialization and teardown
  34. - (id)initWithMovieURL:(NSURL *)newMovieURL size:(CGSize)newSize;
  35. - (id)initWithMovieURL:(NSURL *)newMovieURL size:(CGSize)newSize fileType:(NSString *)newFileType outputSettings:(NSMutableDictionary *)outputSettings;
  36. - (void)setHasAudioTrack:(BOOL)hasAudioTrack audioSettings:(NSDictionary *)audioOutputSettings;
  37. // Movie recording
  38. - (void)startRecording;
  39. - (void)startRecordingInOrientation:(CGAffineTransform)orientationTransform;
  40. - (void)finishRecording;
  41. - (void)finishRecordingWithCompletionHandler:(void (^)(void))handler;
  42. - (void)cancelRecording;
  43. - (void)processAudioBuffer:(CMSampleBufferRef)audioBuffer;
  44. - (void)enableSynchronizationCallbacks;
  45. @end