def run(self): emited = False contador = 0 while ((not emited) and (contador < 3)): try: contador += 1 vss = VideoSnapShooter(self.input_file) vss.snapshoot(self.output_file, self.start_position) time.sleep(0.5) pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size( self.output_file, 300, 300) self.emit('finished', pixbuf) emited = True except Exception as e: time.sleep(0.5) print(e)
def process_file(self, filename): self.filename = filename vss = VideoSnapShooter(filename) mime = mimetypes.guess_type(self.filename) if os.path.exists(self.filename): mime = mimetypes.guess_type(self.filename)[0] if mime in SUPPORTED_MIMES: self.duration_in_seconds = int(vss.get_duration()) self.spinbutton_begin.set_value(0) self.spinbutton_begin.set_editable(True) self.spinbutton_begin.set_adjustment(Gtk.Adjustment(0, 0, self.duration_in_seconds, 1, 10, 0)) self.spinbutton_end.set_value(self.duration_in_seconds) self.spinbutton_end.set_editable(True) self.spinbutton_end.set_adjustment( Gtk.Adjustment(self.duration_in_seconds, 0, self.duration_in_seconds, 1, 10, 0) )