Post

Replies

Boosts

Views

Activity

AVPlayer : Get codec type for all audio tracks available
I am working on a video app and I need to get the codec type and channel number of all audio tracks. I succeed to get this value for the current track via assetTrack :  if ([track.assetTrack.mediaType isEqual:AVMediaTypeAudio]){ AVAssetTrack* assetTrack = track.assetTrack; NSArray* formatDesc = assetTrack.formatDescriptions; for(unsigned int j = 0; j < [formatDesc count]; ++j) { CMAudioFormatDescriptionRef item = (__bridge CMAudioFormatDescriptionRef)[formatDesc objectAtIndex:j]; const AudioStreamBasicDescription* audioDes = CMAudioFormatDescriptionGetStreamBasicDescription (item); if(audioDes) { NSLog(@"channel:%d",audioDes->mChannelsPerFrame); } CMFormatDescriptionRef item2 = (__bridge CMFormatDescriptionRef)[formatDesc objectAtIndex:j]; FourCharCode result = CMFormatDescriptionGetMediaSubType(item2); if(result) { NSLog(@"codec:@%@",[self FourCCString:result]); } } }     How to get these values for the audio tracks not played ? Is it possible or this is a AVPlayer limitation ? Thanks, Fabien
3
0
1.2k
Aug ’22