diff --git a/.idea/misc.xml b/.idea/misc.xml index 53b7407a..2189e580 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/lib/src/androidTest/assets/issue_75/bbb_720p_30mb.mp4 b/lib/src/androidTest/assets/issue_75/bbb_720p_30mb.mp4 new file mode 100644 index 00000000..f29424ee Binary files /dev/null and b/lib/src/androidTest/assets/issue_75/bbb_720p_30mb.mp4 differ diff --git a/lib/src/androidTest/java/com/otaliastudios/transcoder/integration/IssuesTests.kt b/lib/src/androidTest/java/com/otaliastudios/transcoder/integration/IssuesTests.kt index 0cc3ffa9..1ed497a8 100644 --- a/lib/src/androidTest/java/com/otaliastudios/transcoder/integration/IssuesTests.kt +++ b/lib/src/androidTest/java/com/otaliastudios/transcoder/integration/IssuesTests.kt @@ -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 @@ -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 + } } \ No newline at end of file diff --git a/lib/src/main/java/com/otaliastudios/transcoder/internal/audio/remix/AudioRemixer.kt b/lib/src/main/java/com/otaliastudios/transcoder/internal/audio/remix/AudioRemixer.kt index 3458cd0e..1810d0a6 100644 --- a/lib/src/main/java/com/otaliastudios/transcoder/internal/audio/remix/AudioRemixer.kt +++ b/lib/src/main/java/com/otaliastudios/transcoder/internal/audio/remix/AudioRemixer.kt @@ -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() } } } \ No newline at end of file