Fix audio from AVFoundation ts.

This commit is contained in:
Damiano Galassi committed 2016-09-19 15:18:47 +02:00
1 parent 2aa408657c
commit 6ea6c84805
1 file changed
+11
+11
View File
@@ -572,6 +572,17 @@
- (NSUInteger)timescaleForTrack:(MP42Track *)track {
AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:track.sourceId];
// Prefer the asbd sample rate, naturalTimeScale might not be
// the right one if we are reading for .ts
if ([assetTrack.mediaType isEqualToString:AVMediaTypeAudio]) {
CMFormatDescriptionRef formatDescription = (CMFormatDescriptionRef)assetTrack.formatDescriptions.firstObject;
if (formatDescription) {
const AudioStreamBasicDescription *asbd = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription);
return asbd->mSampleRate;
}
}
return assetTrack.naturalTimeScale;
}