![]() |
#1 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 12,566
|
![]()
I posted this in another thread but it really belongs here:
version that detects hue changes more than anything: Code:
//cut detector (color-change detection) //@param pixchgcnt "pixel change count" 40 1 99 50 1 //@param distchg "color change thresh" 50 0 100 50 1 //@gmem=cutdetect input=0; colorspace='YV12'; input_info(input,project_w,project_h); gfx_blit(input); is_chg=0; lf ? ( code = " (sqr(su-u) + sqr(sv-v)) > thr ? (c1 += 1); "; c1 = 0; thr = distchg * 41 / 100; cntreq=pixchgcnt * (project_w*project_h*.25*.01); gfx_evalrect(0,0,project_w,project_h,code,1|2,lf); is_chg = (c1 > cntreq); gfx_img_free(lf); ); lf = gfx_img_hold(input); is_chg && gmem[0] == 0 ? ( last_project_time==0 || project_time > last_project_time + 1.0 || project_time < last_project_time-1.0 ? ( gmem[0] = project_time; last_project_time = project_time; last_project_time == 0.0 ? last_project_time = 0.00000001; ); ); Code:
//cut detector (luminance-change) //@param pixchgcnt "pixel change count" 40 1 99 50 1 //@param distchg "color change thresh" 50 0 100 50 1 //@gmem=cutdetect input=0; colorspace='YV12'; input_info(input,project_w,project_h); gfx_blit(input); is_chg=0; lf ? ( code = " sqr(sy1-y1)+sqr(sy2-y2)+sqr(sy3-y3)+sqr(sy4-y4) > thr ? (c1 += 1); "; c1 = 0; thr = distchg * 41 / 100; cntreq=pixchgcnt * (project_w*project_h*.25*.01); gfx_evalrect(0,0,project_w,project_h,code,1|2,lf); is_chg = (c1 > cntreq); gfx_img_free(lf); ); lf = gfx_img_hold(input); is_chg && gmem[0] == 0 ? ( last_project_time==0 || project_time > last_project_time + 1.0 || project_time < last_project_time-1.0 ? ( gmem[0] = project_time; last_project_time = project_time; last_project_time == 0.0 ? last_project_time = 0.00000001; ); ); And an EEL reascript which adds markers in response to it: Code:
//@gmem=cutdetect function run() ( a = gmem[0]; a != 0.0 ? ( gmem[0] = 0.0; AddProjectMarker(0, 0, a, 0, "cut", -1); ); defer("run();"); ); run(); |
![]() |
![]() |
![]() |
#2 |
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 200
|
![]()
Thanks, Justin!
|
![]() |
![]() |
![]() |
#3 |
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 200
|
![]()
@Justin
I wrote a lua script to creat the marker Code:
it=reaper.GetSelectedMediaItem(0, 0) start=reaper.GetMediaItemInfo_Value(it, "D_POSITION") length=reaper.GetMediaItemInfo_Value(it, "D_LENGTH") fr=reaper.SNM_GetIntConfigVar("projfrbase", -1) d=1/fr reaper.gmem_attach("cutdetect") reaper.gmem_write(0, 0.0) time=math.ceil(length/d) reaper.SetEditCurPos(start, 0, 0) for i=1, time do cur=reaper.GetCursorPosition() reaper.SetEditCurPos(cur+d, 0, 1) pos=reaper.gmem_read(0) if pos~=0 then reaper.AddProjectMarker2(0, 0, pos, 0, "cut:"..i, reaper.CountProjectMarkers(0), 16777471) reaper.gmem_write(0, 0.0) end end |
![]() |
![]() |
![]() |
#4 |
Human being with feelings
Join Date: Jun 2009
Location: brighton, uk
Posts: 12,767
|
![]()
Nice! Will give it a go!
![]()
__________________
subproject FRs click here note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music. |
![]() |
![]() |
![]() |
#5 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 12,566
|
![]() |
![]() |
![]() |
![]() |
#6 | |
Human being with feelings
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,681
|
![]() Quote:
![]() https://forum.cockos.com/showpost.ph...2&postcount=21
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798 Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635 |
|
![]() |
![]() |
![]() |
#7 |
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 200
|
![]()
Thanks Justin and mespotine. Yes running in defer doesn't block the GUI, but it runs as slowly as I play the whole video. Is there any way to get all those gmem[0]~=0 value without actually playing the video?
|
![]() |
![]() |
![]() |
#8 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 12,566
|
![]()
Nope, but you could crank up the project playrate to 4x to get it to run faster...
|
![]() |
![]() |
![]() |
#9 |
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 200
|
![]() |
![]() |
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|