def gatherClicks(t): imdisplay(clip.get_frame(t), screen) objects_to_click = nobjects clicks = [] while objects_to_click: for event in pg.event.get(): if event.type == pg.KEYDOWN: if (event.key == pg.K_BACKSLASH): return "return" elif event.type == pg.MOUSEBUTTONDOWN: x, y = pg.mouse.get_pos() clicks.append((x, y)) objects_to_click -= 1 return clicks if (len(clicks) > 1) else clicks[0]
def gatherClicks(t): imdisplay(clip.get_frame(t), screen) objects_to_click = nobjects clicks = [] while objects_to_click: for event in pg.event.get(): if event.type == pg.KEYDOWN: if (event.key == pg.K_BACKSLASH): return "return" elif event.type == pg.MOUSEBUTTONDOWN: x, y = pg.mouse.get_pos() clicks.append((x, y)) objects_to_click -= 1 return clicks if (len(clicks)>1) else clicks[0]
def gatherClicks(t): imdisplay(clip.get_frame(t), screen) objects_to_click = n_objects clicks = [] while objects_to_click: for event in pg.event.get(): if event.type == pg.KEYDOWN: if event.key == pg.K_BACKSLASH: return "return" elif event.key == pg.K_ESCAPE: raise KeyboardInterrupt() elif event.type == pg.MOUSEBUTTONDOWN: x, y = pg.mouse.get_pos() clicks.append((x, y)) objects_to_click -= 1 return clicks
def preview_clip(clip, fps=60): screen = pygame.display.set_mode(clip.size) result = [] t0 = time.time() loop_clip = True while loop_clip: for t in numpy.arange(1.0 / fps, clip.duration - .001, 1.0 / fps): img = clip.get_frame(t) for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: # if audio: # videoFlag.clear() pygame.quit() return result t1 = time.time() time.sleep(max(0, t - (t1 - t0))) imdisplay(img, screen)
import numpy as np import sys nombreGIFS="northwest" mainClip=VideoFileClip("videos/northwest.webm") segundosDuracion=3 screen = pg.display.set_mode((mainClip.size)) for segundo in np.arange(1.0 / mainClip.fps, mainClip.duration-.001, 1.0 / mainClip.fps): img = mainClip.get_frame(segundo) for event in pg.event.get(): if event.type == pg.KEYDOWN: if event.key == pg.K_ESCAPE: sys.exit() if event.key == pg.K_SPACE: #tecla G print "captura en segundo "+str(segundo) empieza=segundo acaba=segundo+segundosDuracion clip = mainClip.subclip(empieza,acaba).resize(width=400) clip.write_gif("gifs/"+nombreGIFS+str(segundo)+".gif",fps=10,program='ImageMagick',opt='optimizeplus') #dibujar pantalla preview.imdisplay(img, screen)