diff --git a/server/src/main/kotlin/io/github/jsixface/codexvert/api/ConversionApi.kt b/server/src/main/kotlin/io/github/jsixface/codexvert/api/ConversionApi.kt index 2526320..102b073 100644 --- a/server/src/main/kotlin/io/github/jsixface/codexvert/api/ConversionApi.kt +++ b/server/src/main/kotlin/io/github/jsixface/codexvert/api/ConversionApi.kt @@ -139,7 +139,7 @@ class ConversionApi(settingsApi: SettingsApi) { updates.value = 100 } - internal fun buildCommand( + private fun buildCommand( file: VideoFile, convSpecs: List>, outFile: File @@ -148,13 +148,16 @@ class ConversionApi(settingsApi: SettingsApi) { "-hide_banner", "-i", file.path, - *conversionParams(convSpecs).toTypedArray(), + *conversionParams(convSpecs, file).toTypedArray(), outFile.absolutePath ) - internal fun conversionParams(convSpecs: List>): List { + private fun conversionParams(convSpecs: List>, file: VideoFile): List { val result = mutableListOf() - convSpecs.forEachIndexed { i, (track, conv) -> + val subTitleWithoutSpecs = + file.subtitles.filter { convSpecs.none { c -> c.first == it } }.map { it to Conversion.Copy } + val allConversion = convSpecs + subTitleWithoutSpecs + allConversion.forEachIndexed { i, (track, conv) -> when (conv) { Conversion.Copy -> result += listOf(