def playVideo(): clip = VideoFileClip( f'videos/SciFi-teens-p5.mp4' ) #, target_resolution = (largeSize[1],largeSize[0]))#, target_resolution=(480,800)) clip = clip.volumex(0.05) clip = clip.resize(width=800) clip.preview(fullscreen=True)
def play_video(): pygame.display.set_caption( 'VREEA') #Voice Recognition Emotions & Entertainment Assistant clip = VideoFileClip('vreea.mov') clip.preview() pygame.quit()
def intro_movie(self): clip = VideoFileClip('intro.mpeg') clip.preview() self.intro_effect.play() self.draw_text("17.8", 40, WHITE, WIDTH / 2, HEIGHT - 100) pg.display.update() sleep(2)
def run(self, num_steps): # initialize environment obs = self.env.reset() self.vid_frames = [obs] samples = self.env.em.get_audio() self.aud_frames = [samples] start = time.time() for i in range(num_steps): s = time.time() # obs is the video frame #time.sleep(np.random.random()/5*i/1000+0.00) time.sleep(0.01) obs, rew, done, info = self.env.step( self.env.action_space.sample()) vid_frame = obs aud_frame = self.env.em.get_audio() self.render(vid_frame, aud_frame, smooth_audio=True) #print(f"{1 / self.fps / (time.time()-s)}") if done: break print(f"total time {time.time()-start}s") self.clean_up() clip = VideoFileClip('output.mp4') clip.preview()
def playVideo(): """ print(pygame.display.get_wm_info()) movie = "videos/normalvideo.mp4" vlcInstance = vlc.Instance() media = vlcInstance.media_new(movie) player = vlcInstance.media_player_new() #player.set_hwnd(pygame.display.get_wm_info()['window']) winID = pygame.display.get_wm_info()['window'] player.set_xwindow(winID) player.set_position(0.7) player.set_media(media) pygame.mixer.quit() player.play() return player while player.get_state() != vlc.State.Ended: pass player.stop() """ clip = VideoFileClip( f'videos/{eyeDesign}video.mp4') #, target_resolution=(480,800)) clip = clip.volumex(0.05) clip.preview(fullscreen=True)
def main(): icon = pg.image.load('Assets/L.png') pg.display.set_icon(icon) pg.display.set_caption("LOST") clip = VideoFileClip('Assets/intro_video.mpg') clip.preview() main_game = MainGame() main_game.run()
def text_to_clip(vname, sentence_description): video_path = os.path.join(VIDEO_PATH, vname) vname = video_to_frame(video_path) duration = VideoFileClip(video_path).duration global LONG_THRESHOLD global IS_LONG if duration <= LONG_THRESHOLD: print("Processing with a short video!") IS_LONG = False else: print("Processing with a long video!") IS_LONG = True frame_to_fts(vname) video_fts_path = os.path.join(FTS_PATH, vname + ".npy") if IS_LONG: pred_clip, pred_score = ExCL_Locate(video_fts_path, sentence_description, duration) else: pred_clip, pred_score = SCDM_Locate(video_fts_path, sentence_description, duration) if WEB_MODE: clips = [] for i in range(3): clip_dict = {} clip_dict['left'] = round(pred_clip[i][0], 2) clip_dict['right'] = round(pred_clip[i][1], 2) clip_dict['name'] = vname + "_" + sentence_description.replace( ' ', '_') + "_clip%d.mp4" % (i + 1) clip_dict['score'] = round(pred_score[i], 2) clip = VideoFileClip(video_path).subclip(pred_clip[i][0], pred_clip[i][1]) path = os.path.join(CLIP_PATH, clip_dict['name']) if not os.path.exists(path): clip.write_videofile(path) clips.append(clip_dict) return clips else: pygame.display.set_caption('predicted clip') clip1 = VideoFileClip(video_path).subclip(pred_clip[0][0], pred_clip[0][1]) clip2 = VideoFileClip(video_path).subclip(pred_clip[1][0], pred_clip[1][1]) clip3 = VideoFileClip(video_path).subclip(pred_clip[2][0], pred_clip[2][1]) clip = clips_array([[clip1, clip2, clip3]]).resize(width=1000) clip.preview(fps=16, audio=False) pygame.quit()
def music_play(): music_name = str(listbox.get(listbox.curselection())) music_path = str(download_path) + "\\" + str(music_name) music_playing_label = Label(root, text="正在播放:" + music_name, font=('標楷體', 14), bg='red') music_playing_label.grid(row=8, column=0, sticky=W) music_playing_label.update() music_list_update() #print(music_path) #print('正在播放:',music_name) pygame.display.set_caption(music_name) clip = VideoFileClip(music_path) clip.preview() clip.close() pygame.quit() music_playing_label.grid_forget() music_list_update()
def run_round(self): global STATICCOUNTER if STATICCOUNTER == 0: clip = VideoFileClip('naama/momo-skate.mp4') clip.preview() STATICCOUNTER += 1 if self.runner.get_scores() <= self.MAX_SCORE: if not self.__reset_countdown != 0: self.manage_background() self.screen.blit(self.background_1, (self.background_1_x_pos, 0)) self.screen.blit(self.background_2, (self.background_2_x_pos, 0)) self.screen.blit(self.GREY_GENTEMAN, (5, 120)) self.screen.blit(self.runner.get_image(), self.runner.get_position()) self.manage_events() self.manage_obstacles() self.check_flower_collisions() self.manage_flowers() for flower in self.flower: self.screen.blit(flower.get_image(), flower.get_position()) scores_text = self.font.render("scores: " + str(self.runner.get_scores()), True, (0, 0, 0)) self.screen.blit(scores_text, (680, 570)) for obstacle in self.obstacles: self.screen.blit(obstacle.get_image(), obstacle.get_position()) self.check_collisions() else: self.print_end_message() pygame.display.update() else: if self.__end_delay < self.END_DELAY: self.screen.blit(self.background_1, (self.background_1_x_pos, 0)) self.screen.blit(self.background_2, (self.background_2_x_pos, 0)) self.screen.blit(self.runner.get_image(), self.runner.get_position()) self.screen.blit(self.GREY_GENTEMAN, (5, 120)) scores_text = self.font.render("You did it! You may actually save us all!", True, (0, 0, 0)) self.screen.blit(scores_text, (100, 300)) else: self.continue_game = False return self.continue_game
def decide(path, dest1, dest2): """ decide PATH DEST1 DEST2: for all files in PATH, preview each and sort into DEST1 or DEST2 with a single keypress, then automatically advance """ import pygame from moviepy.editor import VideoFileClip print("Press ESC to exit video. Use 'q' to quit deciding.") for filename in glob.glob(os.path.join(path, '*')): just_name = os.path.basename(filename) print(just_name) clip = VideoFileClip(filename) # use ESC key to exit clip.preview() pygame.display.quit() # pygame.quit() clip.close() print("Decide [z, x, or q]: ", end='') sys.stdout.flush() char = '' while char not in ['z', 'x', 'q']: char = getch.getche() print() if char == 'z': destination = os.path.join(dest1, just_name) print("move to {}".format(dest1)) shutil.move(filename, destination) elif char == 'x': destination = os.path.join(dest2, just_name) print("move to {}".format(dest2)) shutil.move(filename, destination) elif char == 'q': print("Exiting") sys.exit()
def __init__(self): pygame.init() mixer.init() self.load_screen = False self.size = (1000, 800) self.window = pygame.display.set_mode((self.size)) self.fps = 60 self.nav_mus = mixer.Sound(r"data/music/navigation.wav") self.intro = pygame.image.load(r"data/images/template.png") self.played = False self.load_settings = False pygame.display.set_caption("Your game name") self.clock = pygame.time.Clock() video = VideoFileClip(r'data/videos/intro.mp4') video.preview() self.colors = { "white": (255, 255, 255), "red": (255, 0, 0), "black": (0, 0, 0), "blue": (0, 0, 255), "green": (0, 255, 0), "test": (100, 60, 40), "bg": (0, 215, 215) } self.locations = [(20, 500, 200, 570), (20, 590, 200, 660), (20, 680, 200, 750)] self.append_rect() self.btn_clr = [ self.colors["test"], self.colors["test"], self.colors["test"] ] self.cpy = self.btn_clr.copy() self.game_loop()
def func1(): pygame.display.set_caption('My video!') clip = VideoFileClip('voronoi.mp4') clip.preview() pygame.quit()
def intro_init(): pg.mouse.set_visible(False) movie = VideoFileClip(INTRO_MOVIE) audio = AudioFileClip(MAIN_MENU_AUDIO) movie = movie.set_audio(audio) movie.preview()
def openning(self): clip = VideoFileClip('open.mp4') clip.preview() sleep(2) self.show_start_screen()
def display_video(self, name): clip = VideoFileClip( os.path.join(ASSETS_PATH, 'videos/' + name + '.mp4')) clip.size = (1200, 750) clip.preview()
def qw(): pygame.display.set_caption('God job!!!!') clip = VideoFileClip('level_complete.mp4') clip.resize(width=10) clip.preview() pygame.quit()
def play_video(): """Play the cinematic.""" clip = VideoFileClip('f_roboc/introduction/movie.mp4') clip.preview(fps=25)
def tutorial(): tutorial = VideoFileClip("sound_video/movie_tutorial.mp4") tutorial.preview(fps=60) return
def playVideo(): clip = VideoFileClip(f'videos/{eyeDesign}video.mp4')#, target_resolution=(480,800)) clip = clip.volumex(0.05) clip.preview(fullscreen = True)
def playVideo(): clip = VideoFileClip('coronavirus.mp4', target_resolution=(480,800)) clip.preview() screen.fill(WHITE)
import imageio imageio.plugins.ffmpeg.download() from moviepy.editor import VideoFileClip import pygame pygame.display.set_caption('My video!') clip = VideoFileClip('babylaugh.mov') clip.preview() pygame.quit()
def play_outro(): pygame.display.set_caption('Tetris - ITNETWORK.cz Summer Competition 2020') clip = VideoFileClip("outro.mp4") clip.preview()
def play_intro(): icon = pygame.image.load(r"finalni_ikona.png") pygame.display.set_icon(icon) pygame.display.set_caption('Tetris - ITNETWORK.cz Summer Competition 2020') clip = VideoFileClip('intro.mp4') clip.preview()
from moviepy.editor import VideoFileClip import pygame pygame.display.set_caption('My video!') clip = VideoFileClip('GIF_loup_raté.mp4') clip.preview() pygame.quit() # # from PIL import Image,ImageTk # from tkinter import * # from tkinter import * # import time # fen = Tk() # can = Canvas(fen, width=350, height=200, bg='white') # can.pack(side='top', fill='both', expand='yes') # photo = PhotoImage(file="img/wolf_short.gif") # can.create_image(0,0,anchor='nw', image=photo, tag='photo') # ind = -1 # def update(delay=200): # global ind # ind += 1 # if ind == 8: ind = 0 # print (ind) # photo.configure(format="gif -index " + str(ind)) # fen.after(delay, update)
def tag(path, config_file): import pygame from moviepy.editor import VideoFileClip # load config file, if provided if config_file: cfg = load_cfg(config_file) if 'tags' not in cfg: cfg['tags'] = [] else: cfg = { 'tags': [] } search_glob = "{}/**".format(path) for filename in glob.iglob(search_glob, recursive=True): if os.path.isfile(filename): just_name = os.path.basename(filename) initial_name = just_name new_name = initial_name print(just_name) new_tags = [] print_tags(cfg) clip = VideoFileClip(filename) # use ESC key to exit clip.preview() pygame.display.quit() # pygame.quit() clip.close() print_tag_prompt(cfg) char = '' while char not in ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'n', 'q']: char = getch.getche() print() if char == 'q': print("\nExiting") sys.exit() elif char == 'n': if new_name != initial_name: pathname = os.path.dirname(filename) destination = os.path.join(pathname, new_name) print("rename as '{}'".format(new_name)) shutil.move(filename, destination) print("Next") elif char in ['1', '2', '3', '4', '5', '6', '7', '8', '9']: tag_idx = int(char)-int('1') tag = cfg['tags'][tag_idx] new_name = tag + ' ' + new_name new_tags.append(tag) print("\nNew tags: {}".format(" ".join(new_tags))) print_tag_prompt(cfg) # prevent from breaking out of loop char = '' else: print("\nError: unrecognized input") print_tag_prompt(cfg)
class Chest(pg.sprite.Sprite): def __init__(self, width, height, pos, screen_width, screen_height, passcode, secret_message, is_ending_chest = False): pg.sprite.Sprite.__init__(self) self.font = pg.font.SysFont(None, 256) self.font.set_bold(True) self.open_image = pg.transform.smoothscale(pg.image.load(os.path.join("Assets", "temp_chest_open_1.png")), (width,height)).convert_alpha() self.closed_image = pg.transform.smoothscale(pg.image.load(os.path.join("Assets", "temp_chest_closed_1.png")), (width,height)).convert_alpha() self.image = self.closed_image self.rect = self.image.get_rect() self.pos = pos self.rect.center = self.pos self.screen_width = screen_width self.screen_height = screen_height self.is_locked = True self.is_interacting = False self.is_digit_pressed = False self.passcode_delay = 0 self.digits = [None, None, None, None] self.passcode = passcode self.secret_message = secret_message self.is_ending_chest = is_ending_chest if self.is_ending_chest: self.ending_clip = VideoFileClip('Assets/ending_video.mpg') else: self.ending_clip = None self.open_sound = pg.mixer.Sound(os.path.join("Assets", "chest_opening.wav")) self.failed_open_sound = pg.mixer.Sound(os.path.join("Assets", "chest_failed_open.wav")) self.enter_number_sound = pg.mixer.Sound(os.path.join("Assets", "enter_number.wav")) self.open_number_panel_sound = pg.mixer.Sound(os.path.join("Assets", "open_number_panel.wav")) self.close_number_panel_sound = pg.mixer.Sound(os.path.join("Assets", "close_number_panel.wav")) def interact(self, paper): self.is_interacting = not self.is_interacting if self.is_interacting: if self.is_locked: pg.mixer.Channel(1).play(self.open_number_panel_sound) self.digits = [None, None, None, None] else: if self.is_ending_chest: self.ending_clip.preview() pg.quit() else: pg.mixer.Channel(1).play(self.open_sound) paper.write(self.secret_message) paper.appear() pass else: if self.is_locked: pg.mixer.Channel(1).play(self.close_number_panel_sound) self.image = self.closed_image self.rect = self.image.get_rect() self.rect.center = self.pos else: paper.dissapear() def _draw_digits(self): block_height = 300 block_width = 180 block_offset = (50,50) block_offset_x_step = ((self.rect.width - 100 - (4 * block_width))//3) + block_width self.image for digit in self.digits: if digit == None: digit_str = '-' else: digit_str = str(digit) rendered_digit = self.font.render(digit_str, True, (200,200,200)) digit_width, digit_height = rendered_digit.get_size() rendered_block = pg.Surface((block_width,block_height)) rendered_block.fill((20,60,80)) digit_offset = (block_width//2 - digit_width//2 + 5, block_height//2 - digit_height//2) rendered_block.blit(rendered_digit, digit_offset) self.image.blit(rendered_block, block_offset) block_offset = (block_offset[0] + block_offset_x_step, block_offset[1]) def update(self, paper): if self.is_interacting: if self.is_locked: if self.digits.count(None) == 0: if self.passcode_delay >= 50: self.passcode_delay = 0 if self.digits == self.passcode: self.is_locked = False self.image = self.open_image self.is_interacting = False self.interact(paper) else: pg.mixer.Channel(1).play(self.failed_open_sound) self.image = self.closed_image self.is_interacting = False self.rect = self.image.get_rect() self.rect.center = self.pos else: self.passcode_delay += 1 else: self.image = pg.Surface((self.screen_width - 200, self.screen_height - 200)) self.image.fill((79, 83, 97)) self.rect = self.image.get_rect() self.rect.center = (self.screen_width//2, self.screen_height//2) keys = pg.key.get_pressed() if not self.is_digit_pressed: if keys[pg.K_0] or keys[pg.K_KP0]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 0 elif keys[pg.K_1] or keys[pg.K_KP1]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 1 elif keys[pg.K_2] or keys[pg.K_KP2]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 2 elif keys[pg.K_3] or keys[pg.K_KP3]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 3 elif keys[pg.K_4] or keys[pg.K_KP4]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 4 elif keys[pg.K_5] or keys[pg.K_KP5]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 5 elif keys[pg.K_6] or keys[pg.K_KP6]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 6 elif keys[pg.K_7] or keys[pg.K_KP7]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 7 elif keys[pg.K_8] or keys[pg.K_KP8]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 8 elif keys[pg.K_9] or keys[pg.K_KP9]: self.is_digit_pressed = True pg.mixer.Channel(1).play(self.enter_number_sound) self.digits[self.digits.index(None)] = 9 elif not (keys[pg.K_0] or keys[pg.K_1] or keys[pg.K_2] or keys[pg.K_3] or keys[pg.K_4] or keys[pg.K_5] or keys[pg.K_6] or keys[pg.K_7] or keys[pg.K_8] or keys[pg.K_9] or keys[pg.K_KP0] or keys[pg.K_KP1] or keys[pg.K_KP2] or keys[pg.K_KP3] or keys[pg.K_KP4] or keys[pg.K_KP5] or keys[pg.K_KP6] or keys[pg.K_KP7] or keys[pg.K_KP8] or keys[pg.K_KP9]): self.is_digit_pressed = False self._draw_digits()
def loop(): clip = VideoFileClip('AVi/momo-code.mp4') clip.preview() global FPSCLOCK, DISPLAYSURF, BASICFONT, BEEP1, BEEP2, BEEP3, BEEP4, highScore FPSCLOCK = pygame.time.Clock() DISPLAYSURF = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT)) pygame.display.set_caption('Simulate') #Insturction message BASICFONT = pygame.font.Font('freesansbold.ttf', 16) infoSurf = BASICFONT.render('Match the pattern. Get to 10 to advance!', 1, DARKGRAY) infoRect = infoSurf.get_rect() infoRect.topleft = (10, WINDOWHEIGHT - 25) # load the sound files BEEP1 = pygame.mixer.Sound('AVi/beep1.ogg') BEEP2 = pygame.mixer.Sound('AVi/beep2.ogg') BEEP3 = pygame.mixer.Sound('AVi/beep3.ogg') BEEP4 = pygame.mixer.Sound('AVi/beep4.ogg')#@TODO: ADD # Initialize some variables for a new game pattern = [] # stores the pattern of colors currentStep = 0 # the color the player must push next lastClickTime = 0 # timestamp of the player's last button push score = 0 # when False, the pattern is playing. when True, waiting for the player to click a colored button: waitingForInput = False replayClick = False # replay was clicked displayMessage(INTROMSG, (3*BUTTONSIZE/2 + 20)) # main game loop while True: if score == 10: displayMessage('YOU WIN!!! ADVANCE! ', 1 * BUTTONSIZE) clip = VideoFileClip('Avi/momo-ending.mp4') clip.preview() return False clickedButton = None # button that was clicked (set to YELLOW, RED, GREEN, or BLUE) DISPLAYSURF.fill(bgColor) drawButtons() scoreSurf = BASICFONT.render('Score: ' + str(score), 1, WHITE) scoreRect = scoreSurf.get_rect() scoreRect.topleft = (WINDOWWIDTH - 100, 10) DISPLAYSURF.blit(scoreSurf, scoreRect) replaySurf = BASICFONT.render("Replay", 1, WHITE) replayRect = replaySurf.get_rect() replayRect.topleft = (10, 10) DISPLAYSURF.blit(replaySurf, replayRect) highScoreSurf = BASICFONT.render('High Score: ' + str(highScore), 1, WHITE) highScoreRect = highScoreSurf.get_rect() highScoreRect.topleft = (WINDOWWIDTH - 120, WINDOWHEIGHT - 25) DISPLAYSURF.blit(highScoreSurf, highScoreRect) DISPLAYSURF.blit(infoSurf, infoRect) drawCages() checkForQuit() for event in pygame.event.get(): # event handling loop if event.type == MOUSEBUTTONUP: mousex, mousey = event.pos clickedButton = getButtonClicked(mousex, mousey) elif event.type == KEYDOWN: if event.key == K_q: clickedButton = YELLOW elif event.key == K_w: clickedButton = BLUE elif event.key == K_a: clickedButton = RED elif event.key == K_s: clickedButton = GREEN#@TODO: ADD if not waitingForInput: # play the pattern if replayClick == False: pygame.display.update() pygame.time.wait(1000) if score%2 == 0: pattern.append(random.choice((YELLOW, BLUE, RED, GREEN, PINK, ORANGE, PURPLE, BROWN)))#@TODO: ADD else: pattern.append(random.choice((YELLOW, BLUE, RED, GREEN, PINK, ORANGE, PURPLE, BROWN))) # @TODO: ADD pattern.append(random.choice((YELLOW, BLUE, RED, GREEN, PINK, ORANGE, PURPLE, BROWN))) # @TODO: ADD for button in pattern: flashButtonAnimation(button) pygame.time.wait(FLASHDELAY) replayClick = False waitingForInput = True else: # wait for the player to enter buttons if (clickedButton == BLACK): replayClick = True waitingForInput = False flashButtonAnimation(clickedButton) elif clickedButton and clickedButton == pattern[currentStep]: # pushed the correct button flashButtonAnimation(clickedButton) currentStep += 1 lastClickTime = time.time() if currentStep == len(pattern): # pushed the last button in the pattern changeBackgroundAnimation() score += 1 waitingForInput = False currentStep = 0 # reset back to first step elif (clickedButton and clickedButton != pattern[currentStep]) or (currentStep != 0 and time.time() - TIMEOUT > lastClickTime): # pushed the incorrect button, or has timed out gameOverAnimation() # reset the variables for a new game: pattern = [] currentStep = 0 waitingForInput = False if score > highScore: highScore = score displayMessage('NEW HIGH SCORE: ' + str(highScore) + " !!!" + " Get 10 points to advance", 2*BUTTONSIZE + 37) score = 0 pygame.time.wait(1000) changeBackgroundAnimation() pygame.display.update() FPSCLOCK.tick(FPS)
def intro_video(): intro = VideoFileClip("sound_video/movie_intro.mp4") intro.preview(fps=60) main_menu()
def video(): pygame.init() pygame.display.set_caption("Swoosh Console") video = VideoFileClip("Animacion.mp4") video.preview() main()
def playVideo(): clip = VideoFileClip('handwashing.mp4', target_resolution=(480, 800)) clip.preview()
def playVideo(): clip = VideoFileClip('videos/normalvideo.mp4', target_resolution=(480, 800)) clip.preview()