Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change error can write #80

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions SDAVAssetExportSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@

@property (nonatomic, weak) id<SDAVAssetExportSessionDelegate> 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.
Expand Down Expand Up @@ -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.
Expand Down
22 changes: 12 additions & 10 deletions SDAVAssetExportSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down