Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Passthrough remixer for more than 2 audio channels #209

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.otaliastudios.transcoder.source.AssetFileDescriptorDataSource
import com.otaliastudios.transcoder.source.BlankAudioDataSource
import com.otaliastudios.transcoder.source.ClipDataSource
import com.otaliastudios.transcoder.source.FileDescriptorDataSource
import com.otaliastudios.transcoder.strategy.DefaultAudioStrategy
import com.otaliastudios.transcoder.strategy.DefaultVideoStrategy
import com.otaliastudios.transcoder.validator.WriteAlwaysValidator
import org.junit.Assume
Expand Down Expand Up @@ -135,4 +136,19 @@ class IssuesTests {
}
Unit
}

@Test(timeout = 16000)
fun issue75_workaround() = with(Helper(75)) {
transcode {
val vds = input("bbb_720p_30mb.mp4")
addDataSource(ClipDataSource(vds, 0, 500_000))
setVideoTrackStrategy(DefaultVideoStrategy.exact(300, 300).build())
// API 23:
// This video seems to have wrong number of channels in metadata (6) wrt MediaCodec decoder output (2)
// so when using DefaultAudioStrategy.CHANNELS_AS_INPUT we target 6 and try to upscale from 2 to 6, which fails
// The workaround below explicitly sets a number of channels different than CHANNELS_AS_INPUT to make it work
// setAudioTrackStrategy(DefaultAudioStrategy.builder().channels(1).build())
}
Unit
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ internal interface AudioRemixer {

companion object {
internal operator fun get(inputChannels: Int, outputChannels: Int): AudioRemixer = when {
inputChannels == outputChannels -> PassThroughAudioRemixer()
inputChannels !in setOf(1, 2) -> error("Input channel count not supported: $inputChannels")
outputChannels !in setOf(1, 2) -> error("Output channel count not supported: $inputChannels")
outputChannels !in setOf(1, 2) -> error("Output channel count not supported: $outputChannels")
inputChannels < outputChannels -> UpMixAudioRemixer()
inputChannels > outputChannels -> DownMixAudioRemixer()
else -> PassThroughAudioRemixer()
else -> DownMixAudioRemixer()
}
}
}