oxyViz
31st August 2014, 23:20
Due to some hardware or software failures moving blue artifacts (see screenshot) sometimes appears on my final encoded videos.
http://forum.doom9.org/attachment.php?attachmentid=14342&stc=1&d=1409523307
Is there any filter or something that allow to find frames with such blue (always blue) blocks?
StainlessS
1st September 2014, 04:43
From RT_Stats (avisynth plugin).
Function RT_RgbInRangeLocate(clip c,int "n"=current_frame,int "Delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,int "Baffle"=8,float "Thresh"=0.0, \
int "RLo"=128,int "RHi"=255,int "GLo"=128,int "GHi"=255,int "BLo"=128,int "BHi"=255, \
String "Prefix"="RGBIRL_",bool "Debug"=false,int "Baffle_W"=Baffle,int "Baffle_H"=Baffle)
Clip function to scan frame n+delta for an area where percentage of pixels in all 3 RGB channels range cLo to cHi (inclusive, c==R or G or B)
breaks a threshold over at least Baffle consecutive number of scanlines (all four sides).
Returns True on Successful location else false. On success sets Global var Coords.
RT_RgbInRangeLocate() tests scanlines from outer most scanlines (h and v), towards inner most, stops where it find Baffle consecutive scanlines
that contain more than Thresh percent of pixels in range cLo to cHi. Object interiors are not tested and so could be hollow.
Would also give +ve result for a disjoint shape like this
--
| |
--
Args:
n: default = current_frame in runtime environment.
Delta: Default = 0
X:Y:W:H: All default=0 as in crop. Area to search, default is full frame.
Baffle: Default=8, minimum number of scanlines that must have a percentage of pixels in range Lo to Hi, greater than Thresh. Avoids noise.
Thresh: Default=0.0 (0.0->100.0). Percentage pixels above which breaks Threshold.
Default is any pixel with all three channels in range cLo to cHi, will break threshold.
RLo: Default 128, lower bound of pixel values of Red Channel to search for.
RHi: Default 255, upper bound of pixel values to Red Channel search for.
GLo: Default 128, lower bound of pixel values of Green Channel to search for.
GHi: Default 255, upper bound of pixel values to Green Channel search for.
BLo: Default 128, lower bound of pixel values of Blue Channel to search for.
BHi: Default 255, upper bound of pixel values to Blue Channel search for.
Prefix: Default "RGBIRL_", prefix for Global Var coords set on successful location of object, eg RGBIRL_X, RGBIRL_Y, RGBIRL_W, RGBIRL_H.
Debug: Default false. If true outputs info to debugView.
Baffle_W, Default Baffle. Thickness of Left and Right side vertical edges, silently limited to width W of search area.
Baffle_H, Default Baffle. Thickness of Top and Bottom horizontal edges, silently limited to height H of search area.
See This post in RT_Stats thread for RT_RgbInRangeLocate() demo script: http://forum.doom9.org/showthread.php?p=1642707&highlight=RT_RGBInRange#post1642707
You would need to convert input to RGB, and determine color of block and if always exact then set eg RLo and RHi the same,
and same for G and B channel args.
Set Baffle_W to blocks width, and Baffle_H to Blocks height (I assume they are the same in which case can just set Baffle instead).
OK, I did a script mod for you, here:
Avisource("Test.avi").ConvertToRGB32 # Your Clip
Dummy = True # False to use YOUR real clip
RED =$00 # Object Color to look for
GREEN =$00
BLUE =$FF
OBJECT_W = 8 # Object Width
OBJECT_H = 8 # Object Height
AREA_X = 0 # Area of frame to search (0,0,0,0=full frame, As Crop)
AREA_Y = 0
AREA_W = -0
AREA_H = -0
R_MIN = RED R_MAX = RED
G_MIN = GREEN G_MAX = GREEN
B_MIN = BLUE B_MAX = BLUE
# Overlay Converts RGB->YUV->RGB (can set inexact color). Use Layer Instead, MUST set ALPHA
RGBA=((255 * 256 + RED)*256+GREEN)*256+BLUE
FN="Findblocks.txt"
# If DUMMY then use Fake clip, for testing
Last = (DUMMY) ? FakeClip(OBJECT_W,OBJECT_H,RGBA) : Last
RT_FileDelete(FN)
ScriptClip ("""
Bingo=RT_RgbInRangeLocate(x=AREA_X,y=AREA_Y,w=AREA_W,h=AREA_H,
\ RLo=R_MIN,Rhi=R_MAX,GLo=G_MIN,Ghi=G_MAX,BLo=B_MIN,Bhi=B_MAX,Baffle_W=OBJECT_W,Baffle_H=OBJECT_H)
S = (Bingo) ? RT_String("%d # @ %d,%d,%d,%d",current_frame,RGBIRL_X,RGBIRL_Y,RGBIRL_W,RGBIRL_H) : RT_String("%d # NOT FOUND",current_frame)
RT_Subtitle("%s",S)
(Bingo) ? RT_TxtWriteFile(S,FN,Append=True) : NOP
Return Last
""")
return Last
Function FakeClip(Int OBJECT_W,Int OBJECT_H, Int RGBA) {
a = BlankClip(length=480,width=480,height=480)
b = a.BlankClip(width=OBJECT_W, height=OBJECT_H, color=RGBA)
a.Animate (0, a.FrameCount () - 1, "Layer", b,"add",257, 0, 0, b,"add",257, 479, 479)
}
If an object of same color in frame then will (if big enough) give false +ve.
Will find objects of at least OBJECT_W,OBJECT_H in size.
Outputs lists of +ve's to file, together with coords.
EDIT: And script to view frames found, Needs FrameSel plugin: http://forum.doom9.org/showthread.php?t=167971
Avisource("Test.avi") # Your Clip
FN="Findblocks.txt"
SHOW=True
FrameSel(Last,cmd=FN,show=SHOW)
EDITED: Added show to show frame number.
EDIT: If multiple blocks, will output outermost coords which encompass all of them.
oxyViz
3rd September 2014, 02:32
Wow, great! I can't even tell how it useful. Many big thanks StainlessS for all your work!
With some tuning of *_MIN and *_MAX values got perfect artifacts detection and now know what to reencode. Thank you again!
Going little away from subject - may be someone can guess what was the cause of this blue blocks, why they are blue, and why no other corruption but only this kind. After days of tests with memtest86+ and prime95 my hardware looks good...
StainlessS
3rd September 2014, 08:11
Perhaps a moderator could approve your pending attachment.
EDIT: By the way, try photobucket.com next time, paste url into post and your pics appear instantly,
(puts moderators out of work, but who cares about that :) )
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.