Skip to content

Instantly share code, notes, and snippets.

@danoli3
Created November 21, 2013 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danoli3/7576852 to your computer and use it in GitHub Desktop.
Save danoli3/7576852 to your computer and use it in GitHub Desktop.
AudioChannelLayout channelLayout;
bzero(&channelLayout, sizeof(channelLayout));
channelLayout.mChannelLayoutTag = kAudioChannelLayoutTag_Mono;
int numOfChannels = 1;
if(channelLayout.mChannelLayoutTag == kAudioChannelLayoutTag_Stereo) {
numOfChannels = 2;
}
NSDictionary * audioOutputSettings = nil;
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_5_1) {
audioOutputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithFloat:preferredHardwareSampleRate], AVSampleRateKey,
[NSNumber numberWithInt:16], AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsNonInterleaved,
[NSNumber numberWithBool:NO], AVLinearPCMIsFloatKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsBigEndianKey,
nil];
} else {
audioOutputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithFloat:preferredHardwareSampleRate], AVSampleRateKey,
[NSNumber numberWithInt:numOfChannels], AVNumberOfChannelsKey,
[NSData dataWithBytes:&channelLayout length:sizeof(AudioChannelLayout)], AVChannelLayoutKey,
[NSNumber numberWithInt:16], AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsNonInterleaved,
[NSNumber numberWithBool:NO], AVLinearPCMIsFloatKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsBigEndianKey,
nil];
}
@danoli3
Copy link
Author

danoli3 commented Nov 21, 2013

AVFoundationVideoPlayer.m:

  • (BOOL)createAssetReaderWithTimeRange:(CMTimeRange)timeRange {

@danoli3
Copy link
Author

danoli3 commented Jan 28, 2014

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[AVAssetReaderTrackOutput initWithTrack:outputSettings:] AVAssetReaderTrackOutput does not currently support AVNumberOfChannelsKey or AVChannelLayoutKey'
*** First throw call stack:
(0x3411b8bf 0x3213d1e5 0x37a71789 0x37a71005 0x41366d 0x412e6d 0x3698cd55 0x36997e8d 0x340ee2dd 0x340714dd 0x340713a5 0x324c6fcd 0x372c7743 0x406507 0xac45 0x8fd8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment