INNER CODE UNIT · Swift

audioTrackInfo

pa-jesusf/KikoFlu · ios/Runner/AppDelegate.swift:511

    private func audioTrackInfo(track: AVAssetTrack) -> (sampleRate: Double, channels: Int) {
        for formatDescription in track.formatDescriptions {
            let audioDescription = formatDescription as! CMAudioFormatDescription
            guard let streamDescription = CMAudioFormatDescriptionGetStreamBasicDescription(audioDescription) else {
                continue
            }
            let sampleRate = streamDescription.pointee.mSampleRate
            let channels = Int(streamDescription.pointee.mChannelsPerFrame)
            if sampleRate > 0 {
                return (sampleRate, max(1, channels))
            }
        }
        return (44_100, 2)
    }

    private func channelCount(from sampleBuffer: CMSampleBuffer) -> Int? {
        guard let formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer),
              let streamDescription = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription) else {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…