This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Automatically remove "black frames"
#5
Can you share a small sample of such a clip (with the black frames)?
I suspect that one could use something like:
def replace_low_luma_frames(clip, threshold):
    # Calculate average luma for each frame
    luma = core.std.ShufflePlanes(clip, planes=0, colorfamily=vs.GRAY)
    avg_luma = core.std.PlaneStats(luma)

    # Create a mask of frames with luma below the threshold
    low_luma_mask = core.std.Expr(avg_luma, f'x {threshold} <')

    # Get frame before for replacement
    frame_before = core.std.Trim(clip, 0, clip.num_frames - 1)

    # Replace frames with low luma using frame_before
    replaced = core.std.MaskedMerge(clip, frame_before, low_luma_mask)

    return replaced

clip = replace_low_luma_frames(clip, 30)
(code is untested, not totally sure whether it works Wink)
to replace each frame which luma is below 30 (or lower) with the frame before it.
Assuming there are only single black frames in the soure and thus singe duplicates that one could use 'FillDrops' to replace the inserted duplicates with interpolated frames.

Cu Selur
Reply


Messages In This Thread
RE: Automatically remove "black frames" - by Selur - 18.05.2023, 18:35

Forum Jump:


Users browsing this thread: 1 Guest(s)