VideoHelp Forum
+ Reply to Thread
Results 1 to 2 of 2
Thread
  1. Hi,

    I have a few sources where the PAR adjustment changes quite differently often, and not always per-scene either.
    I am fiddling with a way to detect pillar boxing, how much, and automatically crop in.

    Code:
    def crop_left_black(clip, maximum=55, threshold=0.10, verbose=True):
        def _(n, f, c):
            for _edge in f:
                amount = _edge.width
                avg = _edge.props["PlaneStatsAverage"]
                is_black = avg < threshold
                if is_black:
                    c = core.resize.Spline16(c, c.width, c.height, src_width=c.width-amount, src_left=amount)
                    if verbose:
                        c = core.text.Text(c, f"Frame #{n} amount {amount}", alignment=9)
                    return c
            return c
    
        edges = [
            core.std.CropAbs(clip, width=i + 1, height=clip.height, left=0).\
                std.PlaneStats()
            for i in reversed(range(maximum))
        ]
    
        return core.std.FrameEval(clip, functools.partial(_, c=clip), prop_src=edges)
    I thought this up, where it just crops in until most pixels are similar in value and a near-0 (black) value.
    But this is fairly slow and ineffective sometimes. In frames where the scene is dark, it often just ends up
    resizing at wacky values, therefore quite noticeable wobble on the horizontal resolution.

    Showcase of Wobble: https://mega.nz/file/IlwQyaiJ#2eMp8gV0DERbkbRChNx3fwxeSDO5PHygfRYcbBZlpjo

    Does anyone have any way to improve this? Some ideas I had were to see if the current "edge" column has similar values to the previous ones.
    Last edited by PRAGMA; 11th Apr 2023 at 00:52.
    Quote Quote  
  2. Shouldn't using for example Stab be used to stabilize the image and then crop the borders?
    Maybe I don't get the issue.
    Last edited by Selur; 11th Apr 2023 at 07:58.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!