Created
July 19, 2020 19:35
-
-
Save The0x539/1cb53e3846469cb7adb7439a7988a608 to your computer and use it in GitHub Desktop.
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
import frame_from_ms, ms_from_frame from aegisub | |
export script_name = 'Fix Bad Shift' | |
export script_description = 'Attempt to fix misaligned timeshifted fbf subs' | |
export script_author = 'The0x539' | |
export script_version = '0.1.0' | |
export script_namespace = '0x.FixBadShift' | |
start_frame = (line) -> frame_from_ms line.start_time | |
end_frame = (line) -> frame_from_ms line.end_time | |
frame_numbers = (line) -> | |
sf = start_frame line | |
ef = end_frame line | |
dur = ef - sf | |
sf, ef, dur | |
main = (subs, sel, _i) -> | |
for i = 1, #sel - 1 | |
idx1, idx2 = sel[i], sel[i + 1] | |
line1, line2 = subs[idx1], subs[idx2] | |
l1_start, l1_end, l1_dur = frame_numbers line1 | |
l2_start, l2_end, l2_dur = frame_numbers line2 | |
if l1_end == l2_start and l1_dur == 2 and l2_dur == 0 | |
new_split = ms_from_frame l1_start + 1 | |
line1.end_time = new_split | |
line2.start_time = new_split | |
subs[idx1], subs[idx2] = line1, line2 | |
aegisub.set_undo_point 'fix bad shift' | |
aegisub.register_macro script_name, script_description, main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment