SHOW:
|
|
- or go back to the newest paste.
1 | ffmpegsource2("C:\Users\Seedmanc\Desktop\[765subs] Ganaha Hibiki - Episode 10.mp4") | |
2 | - | ConvertToYV12 # just to make sure we are in right colorspace no matter what the source is |
2 | + | converttoyv12 |
3 | # boxes sizes | |
4 | - | w=round(312*width/(1280*2)) *2 # this way we get independent from source resolution |
4 | + | w=round(312*width/(1280*2)) *2 # this way we get independent from source resolution |
5 | - | h=round(120*height/(720*2)) *2 # having boxes' coordinates relative instead of absolute |
5 | + | h=round(120*height/(720*2)) *2 # having boxes' coordinates relative instead of absolute |
6 | # coordinates of left box | |
7 | - | xb=round(196*width/(1280*2)) *2 # also this ensures mod2 rule, since video in YV12 format |
7 | + | xb=round(196*width/(1280*2)) *2 # also this ensures mod2 rule, since video in YV12 format |
8 | - | yb=round(322*height/(720*2)) *2 # must have even dimensions |
8 | + | yb=round(322*height/(720*2)) *2 # must have even dimensions |
9 | # coordinates of right box | |
10 | xr=round(770*width/(1280*2)) *2 | |
11 | yr=round(322*height/(720*2)) *2 | |
12 | # we don't need third box, as it is not always present | |
13 | - | src1= crop(xb,yb,w,h).blur(1.58) #source video area of left box |
13 | + | src1= crop(xb,yb,w,h).blur(1.58) # source video area of left box |
14 | bluemask=src1.maskhs(starthue=360-45,endhue=360-7,maxsat=70,minsat=5).converttoyv12.mt_inflate.mt_expand | |
15 | # ^ selection by color blue | |
16 | - | src2= crop(xr,yr,w,h).blur(1.58) #source video area of right box |
16 | + | src2= crop(xr,yr,w,h).blur(1.58) # source video area of right box |
17 | redmask = src2. maskhs(starthue=60, endhue=120, maxsat=75, minsat=10 ) .converttoyv12. mt_inflate. mt_expand | |
18 | # ^ selection by color red | |
19 | comb=mt_logic(bluemask, redmask, mode="min") | |
20 | # ^ combining masks by AND operator - so that detection happens only when both boxes are found | |
21 | - | scriptclip("""AverageLuma(comb )>245 ? \ |
21 | + | xt=round(612*width/(1280*2)) *2 |
22 | - | invert : \ |
22 | + | yt=round(324*height/(720*2)) *2 |
23 | - | last""") |
23 | + | # ^ coordinates of timer |
24 | - | __END__ |
24 | + | wt=round(44*width/(1280*2)) *2 |
25 | - | Here it simply switches to inverted colors when it detects question boxes appearing, just to show that it works. |
25 | + | ht=round(64*height/(720*2)) *2 |
26 | - | 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. |
26 | + | st=round(72*height/(720)) |
27 | # ^ sizes of timer, change 72 in st for font size | |
28 | frame=0 | |
29 | detected=false | |
30 | temp="frame=current_frame detected=true" | |
31 | scriptclip("""(AverageLuma(comb)>245) ? \ | |
32 | eval("(detected==false)?eval(temp):nop \ | |
33 | freezeframe(0,framecount-1,frame) \ | |
34 | overlay(crop(xt,yt,wt,ht).subtitle(string(round(6-(current_frame-frame)/framerate)),size=st,text_color=$00FFFFFF,halo_color=$00FF0088),x=xt,y=yt)") : \ | |
35 | eval( "detected=false last") | |
36 | """) | |
37 | __END__ | |
38 | Now it pauses until question boxes disappear, while showing it's own timer in place of one in the source video. |