rs / SDAVAssetExportSession

AVAssetExportSession drop-in replacement with customizable audio&video settings
MIT License
805 stars 212 forks source link

Fixes bug causing silent videos to crash (no audio track) #9

Closed tifroz closed 10 years ago

tifroz commented 10 years ago

If not accounted for, silent videos (0 audio tracks) would crash on this line:

self.audioOutput = [AVAssetReaderAudioMixOutput assetReaderAudioMixOutputWithAudioTracks:audioTracks audioSettings:nil];

This implements a simple fix by skipping the audioOutput code when no tracks are present in the video file

NSArray *audioTracks = [self.asset tracksWithMediaType:AVMediaTypeAudio];
  if (audioTracks.count > 0) {
    //..do the audio stuffs
  }