Skip to content

Instantly share code, notes, and snippets.

@kwon37xi
Created October 27, 2014 15:57
Show Gist options
  • Save kwon37xi/4039b27f9c04baf050ca to your computer and use it in GitHub Desktop.
Save kwon37xi/4039b27f9c04baf050ca to your computer and use it in GitHub Desktop.
SMI (Video subscript file format) timing sync
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