Created
October 27, 2014 15:57
-
-
Save kwon37xi/4039b27f9c04baf050ca to your computer and use it in GitHub Desktop.
SMI (Video subscript file format) timing sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (args.length < 2) { | |
println "Usage groovy smi_timing filename milliseconds-to-adjust [encoding:default cp949]" | |
System.exit(-1) | |
} | |
def smi = new File(args[0]) | |
def millis = Long.parseLong(args[1]) | |
def encoding = args.length == 3 ? args[2] : "cp949" | |
println "$smi, $millis, $encoding" | |
def text = smi.getText(encoding) | |
// change the pattern | |
def converted = text.replaceAll(/Start=([0-9]+)/) { | |
"Start=" + (Long.parseLong(it[1]) + millis) | |
} | |
smi.setText(converted, encoding) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment