Can you share a small sample of such a clip (with the black frames)?
I suspect that one could use something like:
(code is untested, not totally sure whether it works )
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
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)
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