pythonmoviepy

Remove vfx from clip


Is it possible to remove moviepy vfx effect from clip?

clip = VideoFileClip("file.mp4")
clip.fx(vfx.gamma_corr, 1.9)

clip.fx_remove(vfx.gamma_corr) # not exist in real

(body must be 220 characters, body must be 220 characters)


Solution

  • You are using this kind of wrong

    clip.fx(vfx.gamma_corr, 1.9)
    

    doesn't do anything. As per the documentation, clip.fx returns a new clip, it doesn't modify it inplace. So you should use it like:

    new_clip = clip.fx(vfx.gamma_corr, 1.9)
    

    and then the old clip is still present in the variable clip.

    Now if you still want to reverse the operation to get the original clip back from new_clip

    In the general case, you can't: video effects can be irreversible (destructive) operations.

    In the special case of gamma correction though, that is a nondestructive operation, you can recover the original clip by doing another gamma-correction of factor 1 / gamma where gamma is the original gamma factor.

    so

    old_clip = new_clip.fx(vfx.gamma_corr, 1 / 1.9)