Ejemplo n.º 1
0
def show(clip, t=0, with_mask=True):
    """
    Splashes the frame of clip corresponding to time ``t``.
    
    :param t: time in seconds of the frame to display.
    
    :param with_mask: ``False`` if the clip has a mask but you
         want to see the clip without the mask.
    
    """

    if clip.ismask:
        clip = clip.to_RGB()
    if with_mask and (clip.mask != None):
        import moviepy.video.compositing.CompositeVideoClip as cvc
        clip = cvc.CompositeVideoClip([clip])
    imdisplay(clip.get_frame(t))
Ejemplo n.º 2
0
def show(clip, t=0, with_mask=True, interactive=False):
    """
    Splashes the frame of clip corresponding to time ``t``.
    
    Parameters
    ------------
    
    t
      Time in seconds of the frame to display.
    
    with_mask
      ``False`` if the clip has a mask but you want to see the clip
      without the mask.
    
    """

    if isinstance(t, tuple):
        t = cvsecs(*t)

    if clip.ismask:
        clip = clip.to_RGB()
    if with_mask and (clip.mask != None):
        import moviepy.video.compositing.CompositeVideoClip as cvc
        clip = cvc.CompositeVideoClip([clip.set_pos((0, 0))])
    img = clip.get_frame(t)
    imdisplay(img)

    if interactive:
        result = []
        while True:
            for event in pg.event.get():
                if event.type == pg.KEYDOWN:
                    if (event.key == pg.K_ESCAPE):
                        print("Keyboard interrupt")
                        return result
                elif event.type == pg.MOUSEBUTTONDOWN:
                    x, y = pg.mouse.get_pos()
                    rgb = img[y, x]
                    result.append({'position': (x, y), 'color': rgb})
                    print("position, color : ", "%s, %s" % (str(
                        (x, y)), str(rgb)))
            time.sleep(.03)