def handle_keyboard(source, cond, data): str = source.readline() x = str[0].lower() if x == "p": data.playing = not data.playing data.pipeline.set_state(gst.STATE_PLAYING if data.playing else gst.STATE_PAUSED) print("Setting state to {0}".format("PLAYING" if data.playing else "PAUSE")) elif x == "s": if str[0].isupper(): data.rate *= 2.0 else: data.rate /= 2.0 send_seek_event(data) elif x == "d": data.rate *= -1.0 send_seek_event(data) elif x == "n": if not data.video_sink: # If we have not done so, obtain the sink through which we will send the step events data.video_sink = data.pipeline.get_property("video_sink") data.video_sink.send_event(gst.event_new_step(gst.FORMAT_BUFFERS, 1, data.rate, True, False)) print("Stepping one frame") elif x == "q": data.loop.quit() return True
def handle_keyboard(source, cond, data): str = source.readline() x = str[0].lower() if (x == 'p'): data.playing = not data.playing data.pipeline.set_state(gst.STATE_PLAYING if data.playing else gst.STATE_PAUSED) print ("Setting state to {0}".format("PLAYING" if data.playing else "PAUSE")) elif (x == 's'): if (str[0].isupper()): data.rate *= 2.0 else: data.rate /= 2.0 send_seek_event(data) elif (x == 'd'): data.rate *= -1.0 send_seek_event(data) elif (x == 'n'): cntf = 1 if (len(str) > 2): cntf = int(str[1:len(str)-1]) if (not data.video_sink): #If we have not done so, obtain the sink through which we will send the step events data.video_sink = data.pipeline.get_property("video_sink") isplaying = data.playing if (data.playing): data.pipeline.set_state(gst.STATE_PAUSED) data.video_sink.send_event(gst.event_new_step(gst.FORMAT_BUFFERS, cntf, data.rate, True, False)) if (isplaying): data.pipeline.set_state(gst.STATE_PLAYING) print ("Stepping {0} frame{1}".format( "one" if (cntf == 1) else cntf, "" if (cntf == 1) else "s")) elif (x == 'q'): data.loop.quit() return True
def handle_keyboard(source, cond, data): str = source.readline() x = str[0].lower() if (x == 'p'): data.playing = not data.playing data.pipeline.set_state( gst.STATE_PLAYING if data.playing else gst.STATE_PAUSED) print("Setting state to {0}".format( "PLAYING" if data.playing else "PAUSE")) elif (x == 's'): if (str[0].isupper()): data.rate *= 2.0 else: data.rate /= 2.0 send_seek_event(data) elif (x == 'd'): data.rate *= -1.0 send_seek_event(data) elif (x == 'n'): if (not data.video_sink): #If we have not done so, obtain the sink through which we will send the step events data.video_sink = data.pipeline.get_property("video_sink") data.video_sink.send_event( gst.event_new_step(gst.FORMAT_BUFFERS, 1, data.rate, True, False)) print("Stepping one frame") elif (x == 'q'): data.loop.quit() return True
def step_video_forward(self): if not self.is_video_loaded(): return step_secs = 1 / self.current_framerate step_nanosecs = int(step_secs * gst.SECOND) # step = gst.event_new_step(gst.FORMAT_TIME, step_nanosecs, 1, True,False) step = gst.event_new_step(gst.FORMAT_BUFFERS, 1, 1.0, True, False) self.player.send_event(step)