Created
June 14, 2012 09:13
-
-
Save SAPikachu/2929231 to your computer and use it in GitHub Desktop.
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
FFVideoSource("raw.avi") | |
raw = last | |
WriteFileStart("detection_status.txt", "") | |
ScriptClip(""" | |
raw = last | |
RemoveGrain(mode=19) | |
Repair(TemporalSoften(4,4,8,15,2), last) | |
denoised = last | |
raw | |
Subtitle("Frame: " + string(current_frame)) | |
global diff_to_next = denoised.Crop(0, 16, 0, -16).YDifferenceToNext | |
global diff_to_next_top = raw.Crop(0, 0, 0, 8).YDifferenceToNext | |
global prev_diff_from_prev = denoised.DuplicateFrame(0).Crop(0, 16, 0, -16).YDifferenceFromPrevious | |
global prev_diff_from_prev_bottom = raw.DuplicateFrame(0).Crop(0, height-8, 0, 0).YDifferenceFromPrevious | |
Subtitle("DifferenceToNext (Main): " + string(diff_to_next), y=20) | |
Subtitle("DifferenceToNext (Top): " + string(diff_to_next_top), y=40) | |
Subtitle("(Prev Frame) DifferenceFromPrevious (Main): " + string(prev_diff_from_prev), y=100) | |
Subtitle("(Prev Frame) DifferenceFromPrevious (Bottom): " + string(prev_diff_from_prev_bottom), y=120) | |
function is_bad_frame(float "opt_out_thresh", float "opt_in_thresh") { | |
opt_out_thresh = Default(opt_out_thresh, 30.0) | |
opt_in_thresh = Default(opt_in_thresh, 1.5) | |
opt_out = diff_to_next > opt_out_thresh || prev_diff_from_prev > opt_out_thresh | |
opt_out = opt_out || diff_to_next > diff_to_next_top || prev_diff_from_prev > prev_diff_from_prev_bottom | |
opt_in = diff_to_next_top > diff_to_next * opt_in_thresh || prev_diff_from_prev_bottom > prev_diff_from_prev * opt_in_thresh | |
return opt_in && !opt_out | |
} | |
global detected_is_bad = is_bad_frame() | |
global current_frame = current_frame | |
function glitch_check_status() { | |
status = detected_is_bad == is_glitch ? "Correct" : \ | |
(detected_is_bad ? (diff_to_next < 1 && prev_diff_from_prev < 1 ? "False positive (No problem)" : "False positive") : \ | |
"Missed") | |
return string(current_frame) + ": " + status | |
} | |
Subtitle(glitch_check_status, y=160) | |
WriteFileIf("detection_status.txt", "is_scenecut", "glitch_check_status", append=true, flush=true) | |
""") | |
ConditionalReader("glitch_frames.txt", "is_glitch") | |
ConditionalReader("scenecut.txt", "is_scenecut") | |
StackHorizontal(last, raw.DeleteFrame(0)) | |
StackVertical(StackHorizontal(raw.DuplicateFrame(0).DuplicateFrame(0), raw.DuplicateFrame(0)), last) | |
# Frame list: scenecut.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment