Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
30th January 2022, 23:03 | #1 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
DetBlendFrameSC.avs - EXPERIMENTAL (but works)
Single blended frame at scene change is hard to detect [EDIT: Easier if known 50:50 blend]
and usually prevents scene change detection (looks nasty too). This is not perfect, but is good enough for me to use. Perhaps others may have ideas to make a little more perfect. [Please say if you have better/improved method] Scan complete clip using eg VirtualDub2, "Video Analysis Pass" to create frames file. Clip prompting creation was PAL DVD source, originally from [I think] Canada TV [NTSC ???], perhaps originally on VHS, seemed to be partly progressive, and partly interlaced. [dont think 'clean' enough for anything else but VHS master tape]. Blended frames were originally blended fields before doublerate deinterlacing. Not a totally good conversion from Canadian to PAL DVD. I am applying this after doublerate deinterlacing using QTGMC, partly implemented in DBSC script for blended frame @ Scene change detect, and dynamic border cropping, could not get it working as well as required so stripped out for dedicated script function, later embed back into DBSC. Detects SINGLE frame blend ONLY, not dissolves. No reason why it would not work with HBD converted to 8 bit. [Real result is a frame numbers txt file]. Will Even work on 8 bit RGB [internally converted to Luma-Y], but would be slow compared with external conversion to YUV. The test Doublerate deinterlaced clip I'm using is about 72Mins long [EDIT: after trim of about 50,000 frames), and I'm guessing no more than about 15-20 false +ve blend detects, as only replaces with before or after frame, so very little damage is likely when false detect. Its probably easiest to add/remove any frame number from txt file than try tweak args, have tried to make it autonomous without need of user interaction. [I hope I have suceeded moderately well]. Most false +ve detects that I've noticed, were in a sequence where camera seemed to be in center of a "roundabout" (childs playground whirligig thingy), spinning around very rapidly and pointing at surrounding walls whizzing by in a blur, dont think I could have purposely picked a more difficult clip to test with. EDIT: The Blend frames do not have to be 50/50 blend, can be any ratio. Fluctuating border can badly affect detection, eg top and bottom black line after douberate deinterlace, however, x,y,w,h defaults should avoid those. Code:
# DetBlendFrameSC.avs /* *** EXPERIMENTAL *** Req RT_Stats. DetBlendFrameSC(clip c,String "FramesFile"="BlendFrameSC.txt",Float "dfactor"=0.90,Float "dMin"=40.0, \ int "x"=16,int "y"=16, int "w"=-x, int "h"=-y,Bool "ClipClopIx"=False, Bool "Show"=false, \ Bool "Force_ZOK"=False,Bool "Force_AltOK"=False) Purpose:- To write a frames file of frame numbers that are single frame blend at scene change. (blend of last frame of scene and first frame of following scene). These Target frames are very difficult to detect as scene changes. Can fix blended frame using eg FrameSel or ClipClop, replace with frame before or after the blended frame. To Replace blended frame with eg ClipClop clip 1, use a clip src.DuplicateFrame(0) [replace with previous frame], OR src.DeleteFrame(0) [replace with following frame]. We use a modified result from RT_LumaCorrelation for distance measure between frames. See Pearson’s Distance here: http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient where Pearson's Distance is equivalent to: PD(x,y) = 1.0 - Correlation(x,y) # PD Range 0.0 -> 2.0 However we mod to PD(x,y) = (1.0 - Correlation(x,y)) * 255.0 # Range 0.0 -> 510.0 If detecting too many blends Increase dFactor or dMin, else too few then decrease. See script function for further info */ Function DetBlendFrameSC(clip c,String "FramesFile",Float "dfactor",Float "dMin",int "x",int "y", int "w", int "h",Bool "ClipClopIx",Bool "Show",Bool "Force_ZOK",Bool "Force_AltOK") { c myName = "DetBlendFrameSC: " FramesFile = default(FramesFile,"BlendFrameSC.txt") dFactor = default(dFactor,0.9) dMin = default(dMin,40.0) x = default(x,16) # Test area, allow for ignoring small border/crud, as for crop. y = default(y,16) w = default(w,-x) # default -ve x h = default(h,-y) # default -ve y ClipClopIx = default(ClipClopIx,False) # True precede frame numbers in FramesFile with a ClipClop() index 1, else NO clip index written ie just frame number for eg FrameSel(). show = default(show,False) Force_ZOK = Default(Force_ZOK,False) # Temporary debugging toggle, ZOK always TRUE (Only use AltOK in decision {tuning script - maybe removed later}) Force_AltOK = Default(Force_AltOK,False) # Temporary debugging toggle, AltOK always TRUE (Only use ZOK in decision {tuning script - maybe removed later}) Assert(FramesFile!="",myName+"FramesFile cannot be ''") Assert(0.0 < dFactor < 10.0,myName+"0.0 < dFactor < 10.0") Assert(0.0 <= dMin <= 50.0, myName+"0.0 <= dMin < 50.0") FramesFile = FramesFile.RT_GetFullPathName() FramesFile.RT_FileDelete() FmtS = """ n = current_frame x=%d y=%d w=%d h=%d dFactor=%f dMin=%f ClipClopIx=%s FramesFile="%s" Force_ZOK=%s Force_AltOK=%s Prv = (1 - RT_LumaCorrelation(Last,Last,n=n-1,n2=n ,x=x,y=y,w=w,h=h)) * 255.0 # Distance, prev <-> current Nxt = (1 - RT_LumaCorrelation(Last,Last,n=n ,n2=n+1,x=x,y=y,w=w,h=h)) * 255.0 # Distance, current <-> Next Sum = Prv+Nxt Z = Sum * dFactor + dMin Alt = (1 - RT_LumaCorrelation(Last,Last,n=n-1,n2=n+1,x=x,y=y,w=w,h=h)) * 255.0 # Distance, Prev <-> Next, either side of current pAl = (1 - RT_LumaCorrelation(Last,Last,n=n-2,n2=n ,x=x,y=y,w=w,h=h)) * 255.0 # Distance, either side of previous nAl = (1 - RT_LumaCorrelation(Last,Last,n=n ,n2=n+2,x=x,y=y,w=w,h=h)) * 255.0 # Distance, either side of next ZOK = (Z < Alt) AltHICOR = 0.5 AltLOCOR = 0.65 AltHI = (1.0 - AltHICOR) * 255 # Distance 127.5.00 equivalent to correlation 0.50 AltLO = (1.0 - AltLoCOR) * 255 # Distance 89.25 equivalent to correlation 0.65 AltOK = (Alt > AltHi && (pAl < AltLo || nAl < AltLo)) # ALT must look like scenechange and at least one of prv/nxt ALTs like NOT Scene change # AltOK helps avoid false +ve's, and nearly detects single frame blends OK all on its own. Blend = (ZOK||Force_ZOK) && (AltOK || Force_AltOK) (!Blend) ? NOP : ClipClopIx ? RT_WriteFile(FramesFile,"1 %%d",n,Append=True) : RT_WriteFile(FramesFile,"%%d",n,Append=True) %s Return Last """ SHOW_S = (show) ? """RT_Subtitle("%d] dfact=%.3f : dmin=%.3f\nPrv=%7.3f : Nxt=%7.3f : Sum=%7.3f\n" + \ "pAl=%7.3f : nAl=%7.3f : Alt=%7.3f\nZ=Sum*dFact+dMin=%7.3f : ZOK=(Z<Alt)=%s\nAltOK=(Alt>%.2f&&(pAl<%.2f||nAl<%.2f))=%s\nBlend=(\a%cZOK\a- && \a%cAltOK\a-)=\a%c%s", \ n,dFactor,dMin,Prv,Nxt,Sum,pAl,nAl,Alt,Z,ZOK,AltHi,AltLo,AltLo,AltOK,Force_ZOK?66:ZOK?33:45,Force_AltOK?66:AltOK?33:45,Blend?33:45,Blend) Blend?Subtitle("BLEND",align=5,size=48):NOP""" \ : "" SSS = RT_String(FmtS,x,y,w,h,dFactor,dMin,ClipClopIx,FramesFile,Force_ZOK,Force_AltOK,SHOW_S) # RT_DebugF("%s",SSS,name=myName) RT_WriteFile(".\DetBlendFrameSC_SSS.Log","%s",SSS) # Peruse SSS, if UnComment Return Scriptclip(SSS) } Code:
# Import(".\DetBlendFrameSC.avs") AviSource(".\S01E03.avi") ### CONFIG #### trim(53550,0) #KillAudio SHOW = True ClipClopIx = FALSE # False = FrameSel FORCEWRITE = FALSE # True, force write frames file, and just show "DONE" when finished (will seem to hang for some time). ##### END CONFIG #### SHOW = (FORCEWRITE) ? FALSE : SHOW # Switch OFF SHOW if FORCEWRITE FramesFile=(ClipClopIx) ? "BlendFrameSC_ClipClop.txt" : "BlendFrameSC_FrameSel.txt" # Choose filename based on ClipClopIx DetBlendFrameSC(FramesFile=FramesFile,ClipClopIx=ClipClopIx,show=SHOW) (FORCEWRITE) ? RT_ForceProcess() : NOP (FORCEWRITE) ? MessageClip("DONE") : NOP return Last Detect with Metrics
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 25th November 2022 at 04:49. |
30th January 2022, 23:04 | #2 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Script to View detected frame/s along with before and after frame [Req FrameSel() ].
Code:
# DetBlendFrameSC_FrameSel_VIEW.avs # View Bad frames ONLY [with Previous and Next frames also shown] # MUST HAVE CREATED Framesfile with DetBlendFrameSC(ClipClopIx=FALSE) AviSource(".\S01E03.avi") trim(53550,0) FramesFile = "BlendFrameSC_FrameSel.txt".RT_GetFullPathName ORG=LAST BEFORE = DuplicateFrame(0) # Shift frames 1 frame later than ORG [replacing blended frame with frame prior to it] AFTER = DeleteFrame(0) # Shift frames 1 frame earlier than ORG [replacing blended frame with frame after it] BEFORE = BEFORE.FrameSel(CMD=FramesFile) BAD = ORG.FrameSel(CMD=FramesFile) AFTER = AFTER.FrameSel(CMD=FramesFile) Return StackHorizontal(TSub(BEFORE,"Before"),TSub(BAD,"Bad"),TSub(AFTER,"After")) # Stack Overhead Subtitle Text, with optional FrameNumber shown. Function TSub(clip c,string Tit,Bool "ShowFrameNo",Int "Col"){ c.BlankClip(height=20,Color=Default(Col,0)) (Default(ShowFrameNo,False))?ScriptClip("""Subtitle(String(current_frame,"%.f] """+Tit+""""))"""):Trim(0,-1).Subtitle(Tit) Return StackVertical(c).AudioDubEx(c) }
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 30th January 2022 at 23:34. |
30th January 2022, 23:05 | #3 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Script to fix blend using ClipClop().
Code:
# DetBlendFrameSC_ClipClop_FIX.avs # MUST HAVE CREATED Framesfile with DetBlendFrameSC(ClipClopIx=True) # No change to Audio AviSource(".\S01E03.avi") trim(53550,0) FramesFile = "BlendFrameSC_ClipClop.txt".RT_GetFullPathName ORG=LAST # UnComment ONE of Blow SHIFT = DuplicateFrame(0) # Shift frames 1 frame later than ORG [replacing blended frame with frame prior to it] #SHIFT = DeleteFrame(0) # Shift frames 1 frame earlier than ORG [replacing blended frame with frame after it] SHOW=False SUBS=TRUE STACK=True SHIFT= (SUBS) ? SHIFT.Subtitle("*** FIXED ***",Size=48,align=5) : SHIFT ClipClop(ORG,SHIFT,CMD=FramesFile,SHOW=SHOW) (STACK) ? StackHorizontal(ORG,LasT) : Last
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 30th January 2022 at 23:33. |
30th January 2022, 23:19 | #4 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
This post is reserved for FrameSel FIX script.
(avoid creation of ClipClop version of frames file, use Default Framesel frames file)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
30th October 2022, 23:48 | #5 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Post 1 update.
changed to correlation 0.5 from corr 0.4 Code:
AltHICOR = 0.5 AltLOCOR = 0.8 AltHI = (1.0 - AltHICOR) * 255 # Distance 127.5.00 equivalent to correlation 0.50 AltLO = (1.0 - AltLoCOR) * 255 # Distance 51.00 equivalent to correlation 0.80
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
18th November 2022, 09:32 | #6 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Post #1 function update.
Changed Code:
AltHICOR = 0.5 AltLOCOR = 0.8 AltHI = (1.0 - AltHICOR) * 255 # Distance 127.5.00 equivalent to correlation 0.50 AltLO = (1.0 - AltLoCOR) * 255 # Distance 51.00 equivalent to correlation 0.80 Code:
AltHICOR = 0.5 AltLOCOR = 0.7 AltHI = (1.0 - AltHICOR) * 255 # Distance 127.5.00 equivalent to correlation 0.50 AltLO = (1.0 - AltLoCOR) * 255 # Distance 76.50 equivalent to correlation 0.70 The type of single blended frame scene changes that this detects, may be produced by eg TFM() post processing where it finds unmatched field, eg where there was a scene change on 2nd field of a frame. (or by many deinterlacers on 2nd field scene change) It works really quite well, however I have found at least one instance where flashing frames caused false detect (which more often than not would cause false detect in other detectors too where detecting simple non blended frame scene change). Not sure how much use the "Float "dfactor"=0.9,Float "dMin"=40.0, args are, suggest just use the defaults.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 18th November 2022 at 09:47. |
18th November 2022, 12:00 | #7 | Link |
Banana User
Join Date: Sep 2008
Posts: 989
|
I'll give it a go on one problematic DVD.
Why here are no posts of other people, btw, aren't those screenshots from one of the best tv-movies of all time aka Lexx?
__________________
InpaintDelogo, DoomDelogo, JerkyWEB Fixer, Standalone Faster-Whisper - AI subtitling |
18th November 2022, 12:15 | #8 | Link | |||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Quote:
EDIT: The posted script function is just so I can best gauge settings for DBSC single blend frame SC detect. If you can make it better, than do post fixes. EDIT: Lexx does require TFM(d2v=d2v,...), producing single frame blend SC where postprocessing. EDIT: Suggest, DONT use DGSource(...).TFM(), use DGIndex's Mpeg2Source(d2v).TFM(d2v=d2v,...) Quote:
USA version has chunks chopped out, and I think some story parts changed in order. (try not to get USA versions) Full set tends to be in the £40.00 region, 2nd user, if you can find it. [Not exist on Blu-Ray] EDIT: £28.00 (I paid about £40 - £45):- https://uk.webuy.com/product-detail?...1b3&position=1 EDIT: Lexx on Amazon, £45.00 new [2nd user, is more expensive than new ??? {Maybe new is USA, old non-USA - have not checked}] https://www.amazon.co.uk/Lexx-Comple...s%2C104&sr=8-4 EDIT: YouTube Review:- https://www.google.co.uk/search?q=le...id:dFoP-vijbJo The reviewer dont seem particularly enamoured of Lexx, but thats his problem. [Very low budget just adds to its charm. Me loves it]. Full Intro episode 01:33:xx :- https://www.youtube.com/watch?v=SvqnjEQljYs
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 18th November 2022 at 21:08. |
|||
25th November 2022, 04:47 | #9 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Nuther mod,
Code:
AltHICOR = 0.5 AltLOCOR = 0.7 AltHI = (1.0 - AltHICOR) * 255 # Distance 127.5.00 equivalent to correlation 0.50 AltLO = (1.0 - AltLoCOR) * 255 # Distance 76.50 equivalent to correlation 0.70 Code:
AltHICOR = 0.5 AltLOCOR = 0.65 AltHI = (1.0 - AltHICOR) * 255 # Distance 127.5.00 equivalent to correlation 0.50 AltLO = (1.0 - AltLoCOR) * 255 # Distance 89.25 equivalent to correlation 0.65
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
Tags |
blended frame, scenechange |
|
|