def ProcessEditDecision(tmpFilePath, edit, width, height): """\ Prefab. Applies an edit decision - reading in the relevant video frames and applying the reframing. Outputs the reframed video frames out of the "outbox" outbox. Arguments: - tmpFilePath -- temp directory into which video frames have been saved - edit -- the edit instruction (dictionary containing: "start","end","left","top","right","bottom") - width -- width (in pixels) for output video frames - height -- height (in pixels) for output video frames Inboxes: - "inbox" -- NOT USED - "control" -- Shutdown signalling Outboxes: - "outbox" -- NOT USED - "signal" -- Shutdown signalling """ print " Video segment: ", edit filenames = [ tmpFilePath + "%08d.yuv" % i for i in range(edit["start"], edit["end"] + 1) ] newsize = (width, height) cropbounds = (edit["left"], edit["top"], edit["right"], edit["bottom"]) return Graphline( \ FILENAMES = ForwardIteratingChooser(filenames), FRAME_LOADER = Carousel( lambda filename : Pipeline( 2, MaxSpeedFileReader(filename,chunksize=1024*1024), 2, YUV4MPEGToFrame(), ), make1stRequest=False ), REFRAMING = Pipeline( 2, ToRGB_interleaved(), 2, CropAndScale(newsize, cropbounds), 2, ToYUV420_planar(), ), linkages = { ("FRAME_LOADER", "requestNext") : ("FILENAMES", "inbox"), ("FILENAMES", "outbox") : ("FRAME_LOADER", "next"), ("FRAME_LOADER", "outbox") : ("REFRAMING", "inbox"), ("REFRAMING", "outbox") : ("", "outbox"), ("FILENAMES", "signal") : ("FRAME_LOADER", "control"), ("FRAME_LOADER", "signal") : ("REFRAMING", "control"), ("REFRAMING", "signal") : ("", "signal"), }, boxsizes = { }, )
def player(*argv, **argd): screen = VideoSurface() screen_in_scene = PygameWrapper(wrap=screen, position=(0, 0,-8), rotation=(-30,15,3)).activate() i1 = MatchedTranslationInteractor(target=screen_in_scene).activate() return Pipeline( DiracDecoder(), ToRGB_interleaved(), screen, )
# override pygame display service ogl_display = OpenGLDisplay.getDisplayService(fullscreen=True) PygameDisplay.setDisplayService(ogl_display[0]) READER = Textbox(size=(400, 300), text_height=30).activate() WRITER = TextDisplayer(size=(400, 300), text_height=30).activate() SCREEN = VideoSurface().activate() Pipeline( ReadFileAdaptor("TestMaterial/TrainWindow.drc", readmode="bitrate", bitrate=1000000), DiracDecoder(), MessageRateLimit(10), ToRGB_interleaved(), SCREEN, ).activate() R_ = PygameWrapper(wrap=READER, position=(-2, -2, -10), rotation=(20, 10, 0)).activate() W_ = PygameWrapper(wrap=WRITER, position=(2, 2, -10), rotation=(20, 10, 0)).activate() S_ = PygameWrapper(wrap=SCREEN, position=(-2, 2, -10), rotation=(20, 10, 0)).activate() i1 = MatchedTranslationInteractor(target=R_).activate() i2 = MatchedTranslationInteractor(target=W_).activate() i3 = MatchedTranslationInteractor(target=S_).activate()
def player(*argv, **argd): return Pipeline( DiracDecoder(), ToRGB_interleaved(), VideoSurface(), )