class_docstr: Base class of all clips (VideoClips and AudioClips).
  
  Attributes
  ----------
  
  start : float
    When the clip is included in a composition, time of the
    composition at which the clip starts playing (in seconds).
  
  end : float
    When the clip is included in a composition, time of the
    composition at which the clip stops playing (in seconds).
  
  duration : float
    Duration of the clip (in seconds). Some clips are infinite, in
    this case their duration will be ``None``.
class_docstr_tok: ["Base","class","of","all","clips","(","VideoClips","and","AudioClips",")",".","Attributes","--","--","--","--","--","start",":","float","When","the","clip","is","included","in","a","composition",",","time","of","the","composition","at","which","the","clip","starts","playing","(","in","seconds",")",".","end",":","float","When","the","clip","is","included","in","a","composition",",","time","of","the","composition","at","which","the","clip","stops","playing","(","in","seconds",")",".","duration",":","float","Duration","of","the","clip","(","in","seconds",")",".","Some","clips","are","infinite",",","in","this","case","their","duration","will","be","``","None","``","."]
docstr: General processing of a clip.
  
  Returns a new Clip whose frames are a transformation
  (through function ``func``) of the frames of the current clip.
  
  Parameters
  ----------
  
  func : function
    A function with signature (gf,t -> frame) where ``gf`` will
    represent the current clip's ``get_frame`` method,
    i.e. ``gf`` is a function (t->image). Parameter `t` is a time
    in seconds, `frame` is a picture (=Numpy array) which will be
    returned by the transformed clip (see examples below).
  
  apply_to : {"mask", "audio", ["mask", "audio"]}, optional
    Can be either ``'mask'``, or ``'audio'``, or
    ``['mask','audio']``.
    Specifies if the filter should also be applied to the
    audio or the mask of the clip, if any.
  
  keep_duration : bool, optional
    Set to True if the transformation does not change the
    ``duration`` of the clip.
  
  Examples
  --------
  
  In the following ``new_clip`` a 100 pixels-high clip whose video
  content scrolls from the top to the bottom of the frames of
  ``clip`` at 50 pixels per second.
  
  >>> filter = lambda get_frame,t : get_frame(t)[int(t):int(t)+50, :]
  >>> new_clip = clip.transform(filter, apply_to='mask')
docstr_tok: ["General","processing","of","a","clip",".","Returns","a","new","Clip","whose","frames","are","a","transformation","(","through","function","``","func","``",")","of","the","frames","of","the","current","clip",".","Parameters","--","--","--","--","--","func",":","function","A","function","with","signature","(","gf",",","t","-",">","frame",")","where","``","gf","``","will","represent","the","current","clip","'s","``","get_frame","``","method",",","i.e",".","``","gf","``","is","a","function","(","t-",">","image",")",".","Parameter","`","t","`","is","a","time","in","seconds",",","`","frame","`","is","a","picture","(","=Numpy","array",")","which","will","be","returned","by","the","transformed","clip","(","see","examples","below",")",".","apply_to",":","{","``","mask","''",",","``","audio","''",",","[","``","mask","''",",","``","audio","''","]","}",",","optional","Can","be","either","``","'mask","'","``",",","or","``","'audio","'","``",",","or","``","[","'mask","'",",","'audio","'","]","``",".","Specifies","if","the","filter","should","also","be","applied","to","the","audio","or","the","mask","of","the","clip",",","if","any",".","keep_duration",":","bool",",","optional","Set","to","True","if","the","transformation","does","not","change","the","``","duration","``","of","the","clip",".","Examples","--","--","--","--","In","the","following","``","new_clip","``","a","100","pixels-high","clip","whose","video","content","scrolls","from","the","top","to","the","bottom","of","the","frames","of","``","clip","``","at","50","pixels","per","second",".",">",">",">","filter","=","lambda","get_frame",",","t",":","get_frame","(","t",")","[","int","(","t",")",":","int","(","t",")","+50",",",":","]",">",">",">","new_clip","=","clip.transform","(","filter",",","apply_to='mask","'",")"]
code: def transform(self, func, apply_to=None, keep_duration=True):
      """General processing of a clip.
  
      Returns a new Clip whose frames are a transformation
      (through function ``func``) of the frames of the current clip.
  
      Parameters
      ----------
  
      func : function
        A function with signature (gf,t -> frame) where ``gf`` will
        represent the current clip's ``get_frame`` method,
        i.e. ``gf`` is a function (t->image). Parameter `t` is a time
        in seconds, `frame` is a picture (=Numpy array) which will be
        returned by the transformed clip (see examples below).
  
      apply_to : {"mask", "audio", ["mask", "audio"]}, optional
        Can be either ``'mask'``, or ``'audio'``, or
        ``['mask','audio']``.
        Specifies if the filter should also be applied to the
        audio or the mask of the clip, if any.
  
      keep_duration : bool, optional
        Set to True if the transformation does not change the
        ``duration`` of the clip.
  
      Examples
      --------
  
      In the following ``new_clip`` a 100 pixels-high clip whose video
      content scrolls from the top to the bottom of the frames of
      ``clip`` at 50 pixels per second.
  
      >>> filter = lambda get_frame,t : get_frame(t)[int(t):int(t)+50, :]
      >>> new_clip = clip.transform(filter, apply_to='mask')
  
      """
      if apply_to is None:
          apply_to = []
  
      # mf = copy(self.make_frame)
      new_clip = self.with_make_frame(lambda t: func(self.get_frame, t))
  
      if not keep_duration:
          new_clip.duration = None
          new_clip.end = None
  
      if isinstance(apply_to, str):
          apply_to = [apply_to]
  
      for attribute in apply_to:
          attribute_value = getattr(new_clip, attribute, None)
          if attribute_value is not None:
              new_attribute_value = attribute_value.transform(
                  func, keep_duration=keep_duration
              )
              setattr(new_clip, attribute, new_attribute_value)
  
      return new_clip
  
imports: import copy
  from functools import reduce
  from numbers import Real
  from operator import add
  import numpy
  import proglog
  from moviepy.decorators import apply_to_audio, apply_to_mask, convert_parameter_to_seconds, outplace, requires_duration, use_clip_fps_by_default
label_desc: Use image node_id 4 for calling the Clip obj's underlying member method code with example usage: obj.transform(func, apply_to, keep_duration) and returns: new_clip