GPUImageMovie.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #import <Foundation/Foundation.h>
  2. #import <AVFoundation/AVFoundation.h>
  3. #import "GPUImageContext.h"
  4. #import "GPUImageOutput.h"
  5. /** Protocol for getting Movie played callback.
  6. */
  7. @protocol GPUImageMovieDelegate <NSObject>
  8. - (void)didCompletePlayingMovie;
  9. @end
  10. /** Source object for filtering movies
  11. */
  12. @interface GPUImageMovie : GPUImageOutput
  13. @property (readwrite, retain) AVAsset *asset;
  14. @property (readwrite, retain) AVPlayerItem *playerItem;
  15. @property(readwrite, retain) NSURL *url;
  16. /** This enables the benchmarking mode, which logs out instantaneous and average frame times to the console
  17. */
  18. @property(readwrite, nonatomic) BOOL runBenchmark;
  19. /** This determines whether to play back a movie as fast as the frames can be processed, or if the original speed of the movie should be respected. Defaults to NO.
  20. */
  21. @property(readwrite, nonatomic) BOOL playAtActualSpeed;
  22. /** This determines whether the video should repeat (loop) at the end and restart from the beginning. Defaults to NO.
  23. */
  24. @property(readwrite, nonatomic) BOOL shouldRepeat;
  25. /** This specifies the progress of the process on a scale from 0 to 1.0. A value of 0 means the process has not yet begun, A value of 1.0 means the conversaion is complete.
  26. This property is not key-value observable.
  27. */
  28. @property(readonly, nonatomic) float progress;
  29. /** This is used to send the delete Movie did complete playing alert
  30. */
  31. @property (readwrite, nonatomic, assign) id <GPUImageMovieDelegate>delegate;
  32. @property (readonly, nonatomic) AVAssetReader *assetReader;
  33. @property (readonly, nonatomic) BOOL audioEncodingIsFinished;
  34. @property (readonly, nonatomic) BOOL videoEncodingIsFinished;
  35. /// @name Initialization and teardown
  36. - (id)initWithAsset:(AVAsset *)asset;
  37. - (id)initWithPlayerItem:(AVPlayerItem *)playerItem;
  38. - (id)initWithURL:(NSURL *)url;
  39. - (void)yuvConversionSetup;
  40. /// @name Movie processing
  41. - (void)enableSynchronizedEncodingUsingMovieWriter:(GPUImageMovieWriter *)movieWriter;
  42. - (BOOL)readNextVideoFrameFromOutput:(AVAssetReaderOutput *)readerVideoTrackOutput;
  43. - (BOOL)readNextAudioSampleFromOutput:(AVAssetReaderOutput *)readerAudioTrackOutput;
  44. - (void)startProcessing;
  45. - (void)endProcessing;
  46. - (void)cancelProcessing;
  47. - (void)processMovieFrame:(CMSampleBufferRef)movieSampleBuffer;
  48. @end