diff --git a/SDAVAssetExportSession.h b/SDAVAssetExportSession.h index b954132..33aec49 100644 --- a/SDAVAssetExportSession.h +++ b/SDAVAssetExportSession.h @@ -37,10 +37,15 @@ @property (nonatomic, weak) id delegate; +@property (nonatomic, strong, readonly) AVAssetReader *reader; +@property (nonatomic, strong, readonly) AVAssetWriter *writer; +@property (nonatomic, strong, readonly) dispatch_queue_t inputQueue; + /** * The asset with which the export session was initialized. */ -@property (nonatomic, strong, readonly) AVAsset *asset; +@property (nonatomic, strong) AVAsset *asset; +@property (nonatomic, copy) AVAudioTimePitchAlgorithm audioTimePitchAlgorithm NS_AVAILABLE(10_9, 7_0); /** * Indicates whether video composition is enabled for export, and supplies the instructions for video composition. @@ -123,7 +128,7 @@ * * If there is no error to report, the value of this property is nil. */ -@property (nonatomic, strong, readonly) NSError *error; +@property (nonatomic, strong) NSError *error; /** * The progress of the export on a scale from 0 to 1. diff --git a/SDAVAssetExportSession.m b/SDAVAssetExportSession.m index e99993b..61f99c3 100755 --- a/SDAVAssetExportSession.m +++ b/SDAVAssetExportSession.m @@ -16,14 +16,13 @@ @interface SDAVAssetExportSession () @property (nonatomic, assign, readwrite) float progress; - -@property (nonatomic, strong) AVAssetReader *reader; @property (nonatomic, strong) AVAssetReaderVideoCompositionOutput *videoOutput; @property (nonatomic, strong) AVAssetReaderAudioMixOutput *audioOutput; -@property (nonatomic, strong) AVAssetWriter *writer; @property (nonatomic, strong) AVAssetWriterInput *videoInput; @property (nonatomic, strong) AVAssetWriterInputPixelBufferAdaptor *videoPixelBufferAdaptor; @property (nonatomic, strong) AVAssetWriterInput *audioInput; +@property (nonatomic, strong) AVAssetReader *reader; +@property (nonatomic, strong) AVAssetWriter *writer; @property (nonatomic, strong) dispatch_queue_t inputQueue; @property (nonatomic, strong) void (^completionHandler)(void); @@ -145,13 +144,16 @@ - (void)exportAsynchronouslyWithCompletionHandler:(void (^)(void))handler // NSArray *audioTracks = [self.asset tracksWithMediaType:AVMediaTypeAudio]; if (audioTracks.count > 0) { - self.audioOutput = [AVAssetReaderAudioMixOutput assetReaderAudioMixOutputWithAudioTracks:audioTracks audioSettings:nil]; - self.audioOutput.alwaysCopiesSampleData = NO; - self.audioOutput.audioMix = self.audioMix; - if ([self.reader canAddOutput:self.audioOutput]) - { - [self.reader addOutput:self.audioOutput]; - } + self.audioOutput = [AVAssetReaderAudioMixOutput assetReaderAudioMixOutputWithAudioTracks:audioTracks audioSettings:nil]; + if (self.audioTimePitchAlgorithm) { + self.audioOutput.audioTimePitchAlgorithm = self.audioTimePitchAlgorithm; + } + self.audioOutput.alwaysCopiesSampleData = NO; + self.audioOutput.audioMix = self.audioMix; + if ([self.reader canAddOutput:self.audioOutput]) + { + [self.reader addOutput:self.audioOutput]; + } } else { // Just in case this gets reused self.audioOutput = nil;