def main(): if len(sys.argv) == 2: script = parser.parse(sys.argv[1]) else: script = parser.parse(TESTFILE_PATH) for scene in script.scenes: scene.setting.image = cv2.cvtColor(gi.find_image(scene.setting.name), cv2.COLOR_BGR2RGB) print "Casting..." for character in script.characters.values(): print(character.name) character_data = gi.find_character(character.name) loc, image = character_data print loc character.loc = loc character.image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) ffcv.create_video(script)
# supertitles supertitle_left = text supertitle_y = 0 while len(supertitle_left) > 0: supertitle = supertitle_left while True: text_size = cv2.getTextSize(supertitle, cv2.FONT_HERSHEY_SIMPLEX, 1.0, 2) if text_size[0][0] > HORIZONTAL_RESOLUTION: supertitle = supertitle.rsplit(' ', 1)[0] else: break supertitle_y += 50 text_point = ((HORIZONTAL_RESOLUTION - text_size[0][0])/2, supertitle_y) cv2.putText(frame, supertitle, text_point, cv2.FONT_HERSHEY_SIMPLEX, 1.0, (255, 255, 0), 2) supertitle_left = supertitle_left[len(supertitle):] # write out frame pipe.stdin.write(frame.tostring()) totalframes += 1 while (float(totalframes) / 24.0 - audioManager.curlen()) < .1: frame = draw_scene(setting_image, characters_on_stage, characters_in_background, character, mouths[-1], first_line) pipe.stdin.write(frame.tostring()) totalframes += 1 first_line = False pipe.stdin.close() pipe.wait() audioManager.combineWith('tmp/out.mp4', 'movie.mkv') if __name__=="__main__": script = star_trek_parse.parse('the-defector.txt') create_video(script)
supertitle = supertitle.rsplit(' ', 1)[0] else: break supertitle_y += 50 text_point = ( (HORIZONTAL_RESOLUTION - text_size[0][0]) / 2, supertitle_y) cv2.putText(frame, supertitle, text_point, cv2.FONT_HERSHEY_SIMPLEX, 1.0, (255, 255, 0), 2) supertitle_left = supertitle_left[len(supertitle):] # write out frame pipe.stdin.write(frame.tostring()) totalframes += 1 while (float(totalframes) / 24.0 - audioManager.curlen()) < .1: frame = draw_scene(setting_image, characters_on_stage, characters_in_background, character, mouths[-1], first_line) pipe.stdin.write(frame.tostring()) totalframes += 1 first_line = False pipe.stdin.close() pipe.wait() audioManager.combineWith('tmp/out.mp4', 'movie.mkv') if __name__ == "__main__": script = star_trek_parse.parse('the-defector.txt') create_video(script)