feat: support multiple tracks in audio metadata stripping

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
davotoula
2026-03-18 10:28:13 +01:00
parent 7219c787a6
commit b9d62edaad
@@ -257,8 +257,13 @@ class MetadataStripper {
tempOutputFile = File.createTempFile("stripped_audio_", extension, context.cacheDir) tempOutputFile = File.createTempFile("stripped_audio_", extension, context.cacheDir)
muxer = MediaMuxer(tempOutputFile.absolutePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4) muxer = MediaMuxer(tempOutputFile.absolutePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4)
extractor.selectTrack(0) val trackIndexMap = mutableMapOf<Int, Int>()
val outputTrack = muxer.addTrack(format) for (i in 0 until extractor.trackCount) {
val trackFormat = extractor.getTrackFormat(i)
trackIndexMap[i] = muxer.addTrack(trackFormat)
extractor.selectTrack(i)
}
muxer.start() muxer.start()
muxerStarted = true muxerStarted = true
@@ -269,6 +274,8 @@ class MetadataStripper {
val sampleSize = extractor.readSampleData(buffer, 0) val sampleSize = extractor.readSampleData(buffer, 0)
if (sampleSize < 0) break if (sampleSize < 0) break
val outputTrack = trackIndexMap[extractor.sampleTrackIndex] ?: break
bufferInfo.offset = 0 bufferInfo.offset = 0
bufferInfo.size = sampleSize bufferInfo.size = sampleSize
bufferInfo.presentationTimeUs = extractor.sampleTime bufferInfo.presentationTimeUs = extractor.sampleTime