def dropEvent(self, event): """ Gets called when there is an active drag and the mouse gets released """ if event.mimeData().hasFormat('ubicut/timeable'): # accept MoveAction if timeable was succesfully created if self.current_timeable is not None: if self.drag_from_track: controller = TimelineController.get_instance() t = controller.get_timeable_by_id(self.dragged_timeable_id) self.current_timeable.model.move(self.current_timeable.x_pos) controller.drag_timeable(t.get_info_dict(), self.current_timeable.get_info_dict(), t.model, self.current_timeable.model) event.acceptProposedAction() self.current_timeable = None self.current_timeable_2 = None self.dragged_timeable_id = None # set item_dropped to false for next drag self.item_dropped = False self.update() elif event.mimeData().hasFormat('ubicut/file'): # clear data for next drag self.item_dropped = False if self.current_timeable is not None: self.current_timeable.model.move(self.current_timeable.x_pos) self.current_timeable = None self.current_timeable_2 = None self.update() else: event.ignore()
def __init__(self, name, width, height, x_pos, res_left, res_right, model, view_id, track_id, group_id=None, parent=None): """ Creates a new TimeableView at the specified position on a TrackView. @param name: the name that is displayed in the top left corner of the timeable @param width: timeable width, can be changed while resizing @param height: timeable height, should be the same as track height @param x_pos: position on the track """ super(TimeableView, self).__init__(parent) self.model = model self.model.add_to_timeline() self.name = name self.width = width self.height = height self.x_pos = x_pos self.view_id = view_id self.track_id = track_id self.group_id = group_id self.__controller = TimelineController.get_instance() if self.__controller.is_overlay_track(self.track_id): self.model.corner(True) self.set_pixmap() self.resizable_left = res_left self.resizable_right = res_right self.name_visible = False self.setRect(self.boundingRect()) self.setPos(self.x_pos, 0) self.setFlag(QGraphicsRectItem.ItemIsSelectable, True) self.setFlag(QGraphicsRectItem.ItemSendsGeometryChanges, True) self.setAcceptHoverEvents(True) self.mouse_press_pos = 0 self.mouse_press_start_pos = 0 self.handle_selected = None self.mouse_press_rect = None self.infos_on_click = dict() self.handles = dict() self.update_handles_pos()
def update_time_label(self): current_frame = (self.player.Position() - 1) num_of_frames = (self.get_last_frame() - 1) frame_second = str(int(current_frame % TimelineModel.get_instance().get_fps())) global_frame_seconds = str(int(num_of_frames % TimelineModel.get_instance().get_fps())) if (num_of_frames % TimelineModel.get_instance().get_fps()) >= 10: None else: global_frame_seconds = str("0"+global_frame_seconds) if (current_frame % TimelineModel.get_instance().get_fps()) >= 10: None else: frame_second = str("0"+frame_second) current_time = str(time.strftime('%H:%M:%S', time.gmtime((1 / TimelineModel.get_instance().get_fps()) * current_frame))) num_of_time = str(time.strftime('%H:%M:%S', time.gmtime((1 / TimelineModel.get_instance().get_fps()) * num_of_frames))) timecode = (current_time + ":" + frame_second + " | " + num_of_time + ":" + global_frame_seconds) timecode_timeline = (current_time + ":" + frame_second) self.current_time_label.setText(timecode) TimelineController.get_instance().update_timecode(timecode_timeline)
def load_timeline_widget(self): """ Replaces the 'bottomFrame'-named QObject with a new instance of TimelineView. The widget doesn't have any real content yet after execution of this method. """ splitter = self.findChild(QObject, 'horizontalSplitter') bottom_frame = self.findChild(QObject, 'bottomFrame') i = splitter.indexOf(bottom_frame) TimelineController(self.timeline_view) splitter.replaceWidget(i, self.timeline_view) self.timeline_view.show()
def __start_videoeditor_controller(self, filepath): """ Closes the start window and starts the video-editor window. :param filepath: String: Path to the project file """ video_editor_view = VideoEditorView() timeline_controller = TimelineController.get_instance() timeline_controller.create_default_tracks() self.__video_editor_controller = VideoEditorController( video_editor_view) self.__video_editor_controller.new_project(filepath) self.__start_view.close() self.__video_editor_controller.start()
def __load_project(self): """ Closes the start window and loads the selected project """ # get path from listwidget project_list = self.__start_view.select_project_widget.projects_list_view # return if no project is selected if project_list.currentItem() is None: return path = project_list.currentItem().statusTip() # check if file exists if os.path.isfile(path): self.init_video_editor() with open(path, 'r') as f: project_data = json.load(f) # set up timeline timeline_controller = TimelineController.get_instance() if "timeline" in project_data: timeline_controller.create_project_timeline( project_data["timeline"]) else: timeline_controller.create_default_tracks() # set up filemanager if "filemanager" in project_data: filemanager = self.__video_editor_controller.get_filemanager_controller( ) filemanager.create_project_filemanager( project_data["filemanager"]) if "groups" in project_data: timeline_controller.create_project_groups( project_data["groups"]) # set project path project = Project.get_instance() project.path = path project.changed = False # show videoeditor self.__start_view.close() self.__video_editor_controller.start()
def __init__(self, width, height, num, name, button, is_video, is_overlay=False, parent=None): """ Creates TrackView with fixed width and height. The width and height should be the same for all TrackViews. @param width: track width @param height: track height @param num: the layer of the track, clips in tracks with higher numbers get rendered above others """ super(TrackView, self).__init__(parent) self.width = width self.height = height self.num = num self.name = name self.button = button self.is_overlay = is_overlay self.is_video = is_video # set button context menu policy so you can get a rightclick menu on the button self.button.setContextMenuPolicy(Qt.CustomContextMenu) self.button.customContextMenuRequested.connect(self.on_context_menu) # for drag and drop handling self.item_dropped = False self.current_timeable = None self.current_timeable_2 = None self.drag_from_track = False self.dragged_timeable_id = None self.__controller = TimelineController.get_instance() self.setAcceptDrops(True) self.setup_ui()
def ready(self): """autocut the input files and start the video editor view""" self.progressbar.setValue(0) QApplication.processEvents() self.textlabel.setText(str(Language.current.autocut.inprogress)) self.video_button.setEnabled(False) self.pdf_button.setEnabled(False) self.cancel_button.setEnabled(False) self.ok_button.setEnabled(False) QApplication.processEvents() video_editor_view = VideoEditorView() video_editor_controller = VideoEditorController(video_editor_view) filemanager = video_editor_controller.get_filemanager_controller() try: if self.filename_pdf is not None: filename = os.path.split(self.filename_pdf) filename = filename[-1] filename = filename[:-4] folder = Folder(filename) presentation = Presentation(self.filename_pdf) if not os.path.isdir( os.path.join(self.project_path, self.project_name, 'files', filename)): try: os.mkdir( os.path.join(self.project_path, self.project_name, 'files', filename)) except OSError: pass self.textlabel.setText( str(Language.current.autocut.slidesprogressing)) self.pictures = presentation.convert_pdf( self.project_path, os.path.join(self.project_name, "files", filename), RESOLUTION) for pic in self.pictures: folder.add_to_content(pic) filemanager.file_list.append(folder) except: print("pdf error") pass try: if self.filename_video is not None: video_splitter = VideoSplitter( self.project_path, os.path.join(self.project_name, "files"), self.filename_video) QApplication.processEvents() self.textlabel.setText( str(Language.current.autocut.audioprogress)) audio = video_splitter.cut_audio_from_video() QApplication.processEvents() self.textlabel.setText( str(Language.current.autocut.splittingprogress)) update_progress = lambda progress: self.progressbar.setValue( int(progress * 0.4)) video_splitter.cut_video(update_progress) update_progress2 = lambda progress: self.progressbar.setValue( int(40 + progress * 0.2)) video_splitter.cut_zoom_video(update_progress2) QApplication.processEvents() speaker_video = video_splitter.get_speaker_video() slide_video = video_splitter.get_slide_video() self.textlabel.setText( str(Language.current.autocut.videoanalysis)) QApplication.processEvents() update_progress3 = lambda progress: self.progressbar.setValue( int(60 + progress * 0.2)) board_video = video_splitter.get_board_video() board_video.check_board_area(update_progress3) QApplication.processEvents() update_progress4 = lambda progress: self.progressbar.setValue( int(80 + progress * 0.2)) visualizer_video = video_splitter.get_visualizer_video() visualizer_video.check_visualiser_area(update_progress4) self.textlabel.setText(str(Language.current.autocut.cutting)) QApplication.processEvents() except Exception as e: print(e) return self.progressbar.setValue(100) timeline_controller = TimelineController.get_instance() self.__main_controller.__video_editor_controller = video_editor_controller timeline_controller.create_autocut_tracks() timeline_controller.create_autocut_timeables( speaker_video.get(), 3, board_video.speaker_subvideos) timeline_controller.create_autocut_timeables( board_video.get(), 2, board_video.board_subvideos) timeline_controller.create_autocut_timeables( visualizer_video.get(), 1, visualizer_video.visualizer_subvideos) timeline_controller.add_clip(slide_video.get(), 0) timeline_controller.add_clip(audio.get(), -1) filemanager.addFileNames(self.filename_video) filemanager.addFileNames(board_video.get()) filemanager.addFileNames(visualizer_video.get()) filemanager.addFileNames(slide_video.get()) filemanager.addFileNames(speaker_video.get()) filemanager.addFileNames(audio.get()) self.__autocut_view.close() video_editor_controller.new_project( os.path.join(self.project_path, self.project_name, self.filename)) video_editor_controller.start()