All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mmauro94.mkvtoolnix_wrapper.MkvToolnix.kt Maven / Gradle / Ivy

Go to download

An easy to use light kotlin-jvm wrapper for most common mkvmerge and mkvpropedit CLI commands

The newest version!
package com.github.mmauro94.mkvtoolnix_wrapper

import com.github.mmauro94.mkvtoolnix_wrapper.extract.MkvExtractCommand
import com.github.mmauro94.mkvtoolnix_wrapper.merge.MkvMergeCommand
import com.github.mmauro94.mkvtoolnix_wrapper.propedit.MkvPropEditCommand
import java.io.File

object MkvToolnix {

    /**
     * Calls `mkvmerge --identify` with the the provided file. The JSON result is parsed and a new instance of [MkvToolnixFileIdentification], containing the parsed information
     */
    fun identify(file: File) = MkvToolnixFileIdentification.identify(file)

    /**
     * The path in which to find the MKV Toolnix binaries. Defaults to `null`.
     *
     * When `null` the binaries will be searched in the environment PATH
     */
    var mkvToolnixPath : File? = null

    fun merge(outputFile : File) = MkvMergeCommand(outputFile)

    fun propedit(sourceFile : File) = MkvPropEditCommand(sourceFile)

    fun extract(sourceFile : File) = MkvExtractCommand(sourceFile)

}

internal fun String.mkvtoolnixEscape() : String {
    return replace(" ", "\\s")
        .replace("\"", "\\2")
        .replace(":", "\\c")
        .replace("#", "\\h")
        .replace("\\", "\\\\")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy