Skip to content

Commit

Permalink
Append subtitles to conversion command
Browse files Browse the repository at this point in the history
  • Loading branch information
jsixface committed May 20, 2024
1 parent eef861e commit 74c0ae7
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ConversionApi(settingsApi: SettingsApi) {
updates.value = 100
}

internal fun buildCommand(
private fun buildCommand(
file: VideoFile,
convSpecs: List<Pair<MediaTrack, Conversion>>,
outFile: File
Expand All @@ -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<Pair<MediaTrack, Conversion>>): List<String> {
private fun conversionParams(convSpecs: List<Pair<MediaTrack, Conversion>>, file: VideoFile): List<String> {
val result = mutableListOf<String>()
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(
Expand Down

0 comments on commit 74c0ae7

Please sign in to comment.