Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ffmpegsource2("C:\Users\Seedmanc\Desktop\[765subs] Ganaha Hibiki - Episode 10.mp4")
- ConvertToYV12 # just to make sure we are in right colorspace no matter what the source is
- # boxes sizes
- w=round(312*width/(1280*2)) *2 # this way we get independent from source resolution
- h=round(120*height/(720*2)) *2 # having boxes' coordinates relative instead of absolute
- # coordinates of left box
- xb=round(196*width/(1280*2)) *2 # also this ensures mod2 rule, since video in YV12 format
- yb=round(322*height/(720*2)) *2 # must have even dimensions
- # coordinates of right box
- xr=round(770*width/(1280*2)) *2
- yr=round(322*height/(720*2)) *2
- # we don't need third box, as it is not always present
- src1= crop(xb,yb,w,h).blur(1.58) #source video area of left box
- bluemask=src1.maskhs(starthue=360-45,endhue=360-7,maxsat=70,minsat=5).converttoyv12.mt_inflate.mt_expand
- # ^ selection by color blue
- src2= crop(xr,yr,w,h).blur(1.58) #source video area of right box
- redmask = src2. maskhs(starthue=60, endhue=120, maxsat=75, minsat=10 ) .converttoyv12. mt_inflate. mt_expand
- # ^ selection by color red
- comb=mt_logic(bluemask, redmask, mode="min")
- # ^ combining masks by AND operator - so that detection happens only when both boxes are found
- scriptclip("""AverageLuma(comb )>245 ? \
- invert : \
- last""")
- __END__
- Here it simply switches to inverted colors when it detects question boxes appearing, just to show that it works.
- 245 is the threshold of detection, lower values will make it happen earlier and last longer (since those boxes slide in and out gradually) with the chance of false detection, higher values will do the opposite.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement