fix: revert to actual trackID for audioMix (kCMPersistentTrackID_Invalid never fires tap)
This commit is contained in:
parent
7cfeec1f15
commit
70b264bcc8
@ -356,17 +356,18 @@ final class PlayerRecorder: NSObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建 AudioMix — 用 kCMPersistentTrackID_Invalid 匹配所有音频轨道
|
// 创建 AudioMix — 必须用实际 trackID
|
||||||
// HLS 流在 variant 切换时 audio track ID 会变,绑定具体 ID 会导致 tap 失效
|
// kCMPersistentTrackID_Invalid (=0) 实测不会触发 tap
|
||||||
let inputParams = AVMutableAudioMixInputParameters()
|
let inputParams = AVMutableAudioMixInputParameters()
|
||||||
inputParams.trackID = kCMPersistentTrackID_Invalid
|
inputParams.trackID = audioTrack.trackID
|
||||||
inputParams.audioTapProcessor = tapRef
|
inputParams.audioTapProcessor = tapRef
|
||||||
|
|
||||||
let audioMix = AVMutableAudioMix()
|
let audioMix = AVMutableAudioMix()
|
||||||
audioMix.inputParameters = [inputParams]
|
audioMix.inputParameters = [inputParams]
|
||||||
|
|
||||||
playerItem.audioMix = audioMix
|
playerItem.audioMix = audioMix
|
||||||
NSLog("[Recorder] ✓ Audio tap installed on playerItem, trackID=%d", audioTrack.trackID)
|
NSLog("[Recorder] ✓ Audio tap installed: trackID=%d, asset tracks=%d, playerItem.audioMix set",
|
||||||
|
audioTrack.trackID, playerItem.asset.tracks.count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 开始录制
|
// MARK: - 开始录制
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user