Created
February 15, 2012 07:50
-
-
Save catphive/1834250 to your computer and use it in GitHub Desktop.
code to adjust SRT subtitle timing in emacs
This file contains 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
(defun incr-time (adjust-millis hour minute second milli) | |
(message (format "test %d" adjust-millis)) | |
(let ((total-millis (+ milli (* second 1000) (* minute 60 1000) (* hour 60 60 1000)))) | |
(setq total-millis (+ total-millis adjust-millis)) | |
(format "%02d:%02d:%02d,%03d" | |
(/ total-millis 3600000) | |
(% (/ total-millis 60000) 60) | |
(% (/ total-millis 1000) 60) | |
(% total-millis 1000)))) | |
(defun c5-replace (regexp to-string &optional delimited start end) | |
(replace-regexp regexp | |
(query-replace-compile-replacement to-string t) | |
delimited start end)) | |
(defun fixup (millis) | |
(interactive "nAdjust milliseconds: ") | |
(c5-replace "\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\),\\([0-9]\\{3\\}\\)" | |
(format "\\,(incr-time %d \\#1 \\#2 \\#3 \\#4)" millis))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment