Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Adjust timestamps in an SRT file
adjust_by = 48 # seconds
srt ="~/Downloads/"))
new_srt = srt.
map {|s| s.split("\r\n")}.
map do |i, times, *values|
new_times = times.split(" --> ").map {|t| (Time.strptime(t, "%H:%M:%S,%L") + adjust_by).strftime("%H:%M:%S,%L")}.join(" --> ")
[i, new_times, values.join("\r\n")].join("\r\n")
File.write(File.expand_path("~/Downloads/"), new_srt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.