def __init__(self, frame_action=None, finish_action=None, **kwargs): super(VideoPlayerWidget, self).__init__(**kwargs) if frame_action is None: self.frame_action = self.default_frame else: self.frame_action = frame_action if finish_action is None: self.finish_action = self.default_finish else: self.finish_action = finish_action self.ui = Ui_EmotionVideoPlayer() self.ui.setupUi(self) self.backgroundPalette = QtGui.QPalette() self.backgroundPalette.setColor(QtGui.QPalette.Background, QtGui.QColor(0, 0, 0)) self.setAutoFillBackground(True) self.setPalette(self.backgroundPalette) self.ui.videoPlayer = QtMultimediaWidgets.QVideoWidget() self.ui.gridLayout.addWidget(self.ui.videoPlayer, 1, 1, 1, 1) self.mediaPlayer = QtMultimedia.QMediaPlayer( self, QtMultimedia.QMediaPlayer.VideoSurface) self.video_item = QtMultimediaWidgets.QGraphicsVideoItem() self.mediaPlayer.setVideoOutput(self.ui.videoPlayer) self.mediaPlayer.mediaStatusChanged.connect(self.status_check) self.frameProbe = QtMultimedia.QVideoProbe(self) # self.frameProbe.videoFrameProbed.connect(self.frame) self.frameProbe.setSource(self.mediaPlayer) self.frame_number = 0 self.video = None
def __init__(self, img_rec: ImageRecognition, res_wid: ResultWid, sig_res_wid: SingleResultWid): super(CameraMainWin, self).__init__() self.setupUi(self) # 设置图像处理实例和跳转实例 self.img_rec = img_rec self.res_wid = res_wid self.sig_res_wid = sig_res_wid # camera设置 self.camera = QCamera() self.camera.setCaptureMode(QCamera.CaptureViewfinder) self.cameraOpened = False # 设置相机打开状态为未打开 # 设置取景器分辨率 view_finder_settings = QCameraViewfinderSettings() self.camera.setViewfinderSettings(view_finder_settings) # 初始化取景器 self.viewCamera = QtMultimediaWidgets.QCameraViewfinder(self) self.camera.setViewfinder(self.viewCamera) self.cameraLayout.addWidget(self.viewCamera) # 取景器放置到预留的布局中 # 设置图像捕获 self.capImg = QCameraImageCapture(self.camera) self.capImg.setCaptureDestination(QCameraImageCapture.CaptureToBuffer) self.capImg.imageCaptured.connect(self._process_captured_image) # 绑定按钮槽函数 self.cameraButton.clicked.connect(self.switch_camera) self.captureButton.clicked.connect(self.take_pic) self.loadButton.clicked.connect(self.load_file) self.reconitionButton.clicked.connect(self.load_path) self.chg_mod_Button.clicked.connect(self.change_model)
def __init__(self, source): Media.__init__(self, Media.TYPE_VIDEO, source) DisplayObject.__init__(self) self._videoGraphicsItem = QtMultimediaWidgets.QGraphicsVideoItem() self._videoGraphicsItem.setAspectRatioMode(QtCore.Qt.IgnoreAspectRatio) self._videoGraphicsItem._nativeSizeChangedSlot = lambda size: self._onVideoNativeSizeChanged( size) self._videoGraphicsItem.nativeSizeChanged.connect( self._videoGraphicsItem._nativeSizeChangedSlot) self.source.setVideoOutput(self._videoGraphicsItem)
def create_widgets(self): self.video_widget = QtMultimediaWidgets.QVideoWidget() self.player = QtMultimedia.QMediaPlayer() self.toolbar = QtWidgets.QToolBar() self.file_menu = self.menuBar().addMenu("Fichier") # ACTIONS self.act_open = self.file_menu.addAction(self.open_icon, "Ouvrir") self.act_open.setShortcut("Ctrl+O") self.act_play = self.toolbar.addAction(self.play_icon, "Lire") self.act_previous = self.toolbar.addAction(self.previous_icon, "Revenir au début") self.act_pause = self.toolbar.addAction(self.pause_icon, "Pause") self.act_stop = self.toolbar.addAction(self.stop_icon, "Stop")
def create_widgets(self): """Create the widgets of the application.""" self.video_widget = QtMultimediaWidgets.QVideoWidget() self.player = QtMultimedia.QMediaPlayer() self.toolbar = QtWidgets.QToolBar() self.file_menu = self.menuBar().addMenu("File") # ACTIONS self.act_open = self.file_menu.addAction(self.open_icon, "Open") self.act_open.setShortcut("Ctrl+O") self.act_play = self.toolbar.addAction(self.play_icon, "Play") self.act_previous = self.toolbar.addAction(self.previous_icon, "Back") self.act_pause = self.toolbar.addAction(self.pause_icon, "Pause") self.act_stop = self.toolbar.addAction(self.stop_icon, "Stop")
def __init__(self, parent=None): super().__init__(parent) self.remote_host = None self.port = None self.layout = QtWidgets.QVBoxLayout(self) self.player_widget = QtMultimediaWidgets.QVideoWidget(self) self.layout.addWidget(self.player_widget) self.setLayout(self.layout) self.bar = VideoPlayerBar(self) self.layout.addWidget(self.bar) self.setMinimumSize(500, 500) @vlc.CallbackDecorators.LogCb def log_callback(data, level, ctx, fmt, args): self._log_callback(level, fmt, args) self._callback = log_callback self._instance = vlc.Instance() self._instance.log_set(log_callback, None) self._player = self._instance.media_player_new() if platform.system() == "Linux": # for Linux using the X Server self._player.set_xwindow(int(self.player_widget.winId())) elif platform.system() == "Windows": # for Windows self._player.set_hwnd(int(self.player_widget.winId())) elif platform.system() == "Darwin": # for MacOS self._player.set_nsobject(int(self.player_widget.winId())) else: raise RuntimeError("Multimedia is not supported on this platform") self._timer = QtCore.QTimer(self) self._timer.setSingleShot(False) self._timer.setInterval(100) self._timer.timeout.connect(self._update_ui) self._update_ui() self.bar.video_state.connect(self.handle_video_state_update) self.bar.video_set_point_in_time.connect(self.handle_slider_change)
dockWidget.setWidget(tLabel) self.addDockWidget(Qt.LeftDockWidgetArea, dockWidget) if __name__ == "__main__": import sys testApp = QApplication(sys.argv) testApp.setApplicationName("영상나오니?") mainWindow = MediaArea() mainWindow.resize(400, 300) tLabel = QLabel(mainWindow) tLabel.resize(300, 200) vWidget = QtMultimediaWidgets.QVideoWidget(mainWindow) vWidget.resize(mainWindow.size()) # vWidget = QtMultimediaWidgets.QVideoWidget(tLabel) # media area player = QtMultimedia.QMediaPlayer(mainWindow) # player = QtMultimedia.QMediaPlayer(tLabel) player.setMedia(QUrl.fromLocalFile("D:\\SampleData\\albamonSample.mp4")) # player.setMedia(QUrl.fromLocalFile("D:\\videoSample\\E01.mp4")) player.setVideoOutput(vWidget) # playList = QtMultimedia.QMediaPlaylist(player) # playList.addMedia(QUrl.fromLocalFile("D:/SampleData/albamonSample.mp4")) # frame = QtMultimedia.QVideoFrame(player)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(917, 663) self.menu_widget = QtWidgets.QWidget(Form) self.menu_widget.setGeometry(QtCore.QRect(10, 10, 131, 641)) self.menu_widget.setObjectName("menu_widget") self.menu1_widget = QtWidgets.QWidget(self.menu_widget) self.menu1_widget.setGeometry(QtCore.QRect(4, 10, 121, 41)) self.menu1_widget.setObjectName("menu1_widget") self.menu_btn = QtWidgets.QPushButton(self.menu1_widget) self.menu_btn.setGeometry(QtCore.QRect(20, 10, 75, 23)) self.menu_btn.setObjectName("menu_btn") self.menu_btn.setCheckable(True) self.menu_btn.toggle() self.menu_btn.clicked.connect(self.menu_btn_clicked) self.menu2_widget = QtWidgets.QWidget(self.menu_widget) self.menu2_widget.setGeometry(QtCore.QRect(3, 70, 121, 111)) self.menu2_widget.setObjectName("menu2_widget") self.vid_btn = QtWidgets.QPushButton(self.menu2_widget) self.vid_btn.setGeometry(QtCore.QRect(20, 20, 75, 23)) self.vid_btn.setObjectName("vid_btn") self.vid_btn.setCheckable(True) self.vid_btn.toggle() self.vid_btn.clicked.connect(self.vid_btn_clicked) self.heat_btn = QtWidgets.QPushButton(self.menu2_widget) self.heat_btn.setGeometry(QtCore.QRect(20, 50, 75, 23)) self.heat_btn.setObjectName("heat_btn") self.heat_btn.setCheckable(True) self.heat_btn.toggle() self.heat_btn.clicked.connect(self.heat_btn_clicked) self.gridLayoutWidget = QtWidgets.QWidget(Form) self.gridLayoutWidget.setGeometry(QtCore.QRect(150, 10, 761, 641)) self.gridLayoutWidget.setObjectName("gridLayoutWidget") self.main_lay = QtWidgets.QGridLayout(self.gridLayoutWidget) self.main_lay.setContentsMargins(0, 0, 0, 0) self.main_lay.setObjectName("main_lay") self.vid_lay = QtWidgets.QGridLayout() self.vid_lay.setObjectName("vid_lay") self.vid_widget = QtWidgets.QWidget(self.gridLayoutWidget) self.vid_widget.setObjectName("vid_widget") self.video_widget = QtWidgets.QWidget(self.vid_widget) self.video_widget.setGeometry(QtCore.QRect(20, 110, 331, 331)) self.video_widget.setObjectName("video_widget") self.verticalLayoutWidget = QtWidgets.QWidget(self.vid_widget) self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 10, 371, 80)) self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") self.videoMenu_VLayout = QtWidgets.QVBoxLayout( self.verticalLayoutWidget) self.videoMenu_VLayout.setContentsMargins(0, 0, 0, 0) self.videoMenu_VLayout.setObjectName("videoMenu_VLayout") self.dateMenu_HLayout = QtWidgets.QHBoxLayout() self.dateMenu_HLayout.setObjectName("horizontalLayout") self.dateLabel = QtWidgets.QLabel(self.verticalLayoutWidget) self.dateLabel.setObjectName("dateLabel") self.dateMenu_HLayout.addWidget(self.dateLabel) self.dateEdit = QtWidgets.QDateEdit(self.verticalLayoutWidget) self.dateEdit.setObjectName("dateEdit") self.dateMenu_HLayout.addWidget(self.dateEdit) self.videoMenu_VLayout.addLayout(self.dateMenu_HLayout) self.timeLabel_HLayout = QtWidgets.QHBoxLayout() self.timeLabel_HLayout.setObjectName("horizontalLayout_2") self.timeLabel = QtWidgets.QLabel(self.verticalLayoutWidget) self.timeLabel.setObjectName("label_2") self.timeLabel_HLayout.addWidget(self.timeLabel) self.timeEdit_1 = QtWidgets.QTimeEdit(self.verticalLayoutWidget) self.timeEdit_1.setObjectName("timeEdit") self.timeLabel_HLayout.addWidget(self.timeEdit_1) self.timeEdit_2 = QtWidgets.QTimeEdit(self.verticalLayoutWidget) self.timeEdit_2.setObjectName("timeEdit_2") self.timeLabel_HLayout.addWidget(self.timeEdit_2) self.videoMenu_VLayout.addLayout(self.timeLabel_HLayout) self.total_videoBtn_HLayout = QtWidgets.QWidget(self.vid_widget) self.total_videoBtn_HLayout.setGeometry(QtCore.QRect(70, 460, 231, 80)) self.total_videoBtn_HLayout.setObjectName("videoBtn_HLayout") self.videoBtn_HLayout = QtWidgets.QHBoxLayout( self.total_videoBtn_HLayout) self.videoBtn_HLayout.setContentsMargins(0, 0, 0, 0) self.videoBtn_HLayout.setObjectName("horizontalLayout_3") self.playBtn = QtWidgets.QPushButton(self.total_videoBtn_HLayout) self.playBtn.setObjectName("playBtn") self.playBtn.clicked.connect(self.play_btn_clicked) self.videoBtn_HLayout.addWidget(self.playBtn) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.videoBtn_HLayout.addItem(spacerItem) self.stopBtn = QtWidgets.QPushButton(self.total_videoBtn_HLayout) self.stopBtn.setObjectName("pushButton_2") self.stopBtn.clicked.connect(self.stop_btn_clicked) self.videoBtn_HLayout.addWidget(self.stopBtn) self.vid_lay.addWidget(self.vid_widget, 0, 1, 1, 1) self.main_lay.addLayout(self.vid_lay, 0, 0, 1, 1) self.heat_lay = QtWidgets.QGridLayout() self.heat_lay.setObjectName("heat_lay") self.heat_widget = QtWidgets.QWidget(self.gridLayoutWidget) self.heat_widget.setObjectName("heat_widget") self.heat_label = QtWidgets.QLabel(self.heat_widget) self.heat_label.setGeometry(QtCore.QRect(10, 10, 56, 12)) self.heat_label.setObjectName("heat_label") self.time_check = QtWidgets.QCheckBox(self.heat_widget) self.time_check.setGeometry(QtCore.QRect(10, 33, 81, 16)) self.time_check.setObjectName("time_check") self.start_time = QtWidgets.QTimeEdit(self.heat_widget) self.start_time.setGeometry(QtCore.QRect(100, 30, 118, 22)) self.start_time.setObjectName("start_time") self.end_time = QtWidgets.QTimeEdit(self.heat_widget) self.end_time.setGeometry(QtCore.QRect(230, 30, 118, 22)) self.end_time.setObjectName("end_time") self.img_label = QtWidgets.QLabel(self.heat_widget) self.img_label.setGeometry(QtCore.QRect(10, 70, 56, 12)) self.img_label.setText("") self.img_label.setObjectName("img_label") self.heat_lay.addWidget(self.heat_widget, 0, 0, 1, 1) self.main_lay.addLayout(self.heat_lay, 0, 1, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) self.menu_mainPage() # video player widget self.vWidget = QtMultimediaWidgets.QVideoWidget(self.video_widget) self.vWidget.resize(self.video_widget.size()) # media area self.player = QtMultimedia.QMediaPlayer(self.video_widget) self.vid_name = "C:/Users/bit/Downloads/out (2).mp4" self.player.setMedia(QUrl.fromLocalFile(self.vid_name)) self.player.setVideoOutput(self.vWidget) self.img_label = QtWidgets.QLabel(self.heat_widget) self.img_label.setGeometry(QtCore.QRect(10, 80, 640, 360)) self.img_label.setObjectName("img_label") # self.img_label.setBackgroundRole(QtGui.QPalette.Base) # self.img_label.setSizePolicy(QtWidgets.QSizePolicy.Ignored, # QtWidgets.QSizePolicy.Ignored) self.img_label.setScaledContents(True) self.file_name = "C:/Users/bit/Anaconda3/envs/qt/qt/cat.jpg" image = QtGui.QImage(self.file_name) if image.isNull(): QtGui.QMessageBox.information(self, "Image Viewer", "Cannot load %s." % self.file_name) self.img_label.setPixmap(QtGui.QPixmap.fromImage(image))
def createWidgets(self): self.mainWidget = QtWidgets.QWidget(self) self.setCentralWidget(self.mainWidget) # UTILS boldFont = QtGui.QFont() boldFont.setBold(True) # VIDEO self.mediaPlayer = QtMultimedia.QMediaPlayer( None, QtMultimedia.QMediaPlayer.VideoSurface) self.videoWidget = QtMultimediaWidgets.QVideoWidget() self.frameCounter = QtWidgets.QLineEdit() self.frameCounter.setMaximumSize(40, 20) self.frameCounter.setFrame(False) self.frameCounter.setFont(boldFont) self.frameCounter.setStyleSheet("background-color: rgba(0, 0, 0, 0);") self.frameCounter.setValidator(QtGui.QIntValidator(-9999, 9999)) self.frameCounter.setEnabled(False) self.mediaPlayer.setVideoOutput(self.videoWidget) self.videoWidget.show() # TIMELINE self.playBackOffset = QtWidgets.QLineEdit() self.playBackStart = QtWidgets.QLineEdit() self.timeSlider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.playBackEnd = QtWidgets.QLineEdit() self.videoEnd = QtWidgets.QLineEdit() self.playBackOffset.setValidator(QtGui.QIntValidator(-9999, 9999)) self.playBackStart.setValidator(QtGui.QIntValidator(-9999, 9999)) self.playBackEnd.setValidator(QtGui.QIntValidator(-9999, 9999)) self.videoEnd.setValidator(QtGui.QIntValidator(-9999, 9999)) self.playBackOffset.setMaximumWidth(35) self.playBackStart.setMaximumWidth(35) self.playBackEnd.setMaximumWidth(35) self.videoEnd.setMaximumWidth(35) self.timeSlider.setRange(0, 0) self.timeSlider.setTickPosition(QtWidgets.QSlider.TicksBothSides) # Default values self.playBackOffset.setEnabled(False) self.videoEnd.setEnabled(False) self.playBackOffset.setText(str(0)) self.videoEnd.setText(str(0)) self.playBackStart.setText(str(0)) self.playBackEnd.setText(str(0)) # CONTROLS self.syncCheckBox = QtWidgets.QCheckBox() self.frameRateLabel = QtWidgets.QLabel() self.syncLabel = QtWidgets.QLabel("Sync") self.backToStartButton = QtWidgets.QPushButton() self.frameBackButton = QtWidgets.QPushButton() self.playButton = QtWidgets.QPushButton() self.frameForwardButton = QtWidgets.QPushButton() self.toEndButton = QtWidgets.QPushButton() self.muteButton = QtWidgets.QPushButton() self.volumeSlider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.backToStartButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_MediaSkipBackward)) self.frameBackButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_MediaSeekBackward)) self.playButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_MediaPlay)) self.frameForwardButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_MediaSeekForward)) self.toEndButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_MediaSkipForward)) self.muteButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_MediaVolume)) self.muteButton.setFlat(True) self.volumeSlider.setMaximumWidth(60) self.volumeSlider.setRange(0, 100) self.volumeSlider.setValue(100) for btn in [ self.playButton, self.backToStartButton, self.frameBackButton, self.frameForwardButton, self.toEndButton ]: btn.setEnabled(False) btn.setFlat(True)
def __init__(self): """MainWindow constructor""" super().__init__() base_widget = qtw.QWidget() base_widget.setLayout(qtw.QHBoxLayout()) notebook = qtw.QTabWidget() base_widget.layout().addWidget(notebook) self.file_list = qtw.QListWidget() base_widget.layout().addWidget(self.file_list) self.setCentralWidget(base_widget) toolbar = self.addToolBar('Transport') record_act = toolbar.addAction('Rec') stop_act = toolbar.addAction('Stop') play_act = toolbar.addAction('Play') pause_act = toolbar.addAction('Pause') self.video_dir = qtc.QDir.home() if not self.video_dir.cd('captains_log'): qtc.QDir.home().mkdir('captains_log') self.video_dir.cd('captains_log') self.refresh_video_list() self.player = qtmm.QMediaPlayer() self.video_widget = qtmmw.QVideoWidget() self.player.setVideoOutput(self.video_widget) notebook.addTab(self.video_widget, 'Play') play_act.triggered.connect(self.player.play) pause_act.triggered.connect(self.player.pause) stop_act.triggered.connect(self.player.stop) play_act.triggered.connect( lambda: notebook.setCurrentWidget(self.video_widget)) self.file_list.itemDoubleClicked.connect(self.on_file_selected) self.file_list.itemDoubleClicked.connect( lambda: notebook.setCurrentWidget(self.video_widget)) self.camera = self.camera_check() if not self.camera: self.show() return self.camera.setCaptureMode(qtmm.QCamera.CaptureVideo) self.cvf = qtmmw.QCameraViewfinder() self.camera.setViewfinder(self.cvf) notebook.addTab(self.cvf, 'Record') self.camera.start() self.recorder = qtmm.QMediaRecorder(self.camera) settings = self.recorder.videoSettings() settings.setResolution(640, 480) settings.setFrameRate(24.0) settings.setQuality(qtmm.QMultimedia.VeryHighQuality) self.recorder.setVideoSettings(settings) record_act.triggered.connect(self.record) record_act.triggered.connect( lambda: notebook.setCurrentWidget(self.cvf)) pause_act.triggered.connect(self.recorder.pause) stop_act.triggered.connect(self.recorder.stop) stop_act.triggered.connect(self.refresh_video_list) self.show()
def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle('Video Splitter') self.playlist = QtMultimedia.QMediaPlaylist() self.player = QtMultimedia.QMediaPlayer() # Setting QToolBar tool_bar = QtWidgets.QToolBar() tool_bar.setWindowTitle('Toolbar') self.addToolBar(tool_bar) file_menu = self.menuBar().addMenu("&File") # Define actions for in the file menu open_action = QtWidgets.QAction("Open", self, shortcut="Ctrl+O", triggered=self.open) exit_action = QtWidgets.QAction( "E&xit", self, shortcut="Ctrl+Q", triggered=QtWidgets.QApplication.instance().quit) file_menu.addAction(open_action) file_menu.addAction(exit_action) play_menu = self.menuBar().addMenu("&Play") # add icons and actions # Play play_icon = self.style().standardIcon(QtWidgets.QStyle.SP_MediaPlay) self.play_action = tool_bar.addAction(play_icon, "Play") self.play_action.triggered.connect(self.player.play) play_menu.addAction(self.play_action) # Pause pause_icon = self.style().standardIcon(QtWidgets.QStyle.SP_MediaPause) self.pause_action = tool_bar.addAction(pause_icon, "Pause") self.pause_action.triggered.connect(self.player.pause) play_menu.addAction(self.pause_action) # Stop stop_icon = self.style().standardIcon(QtWidgets.QStyle.SP_MediaStop) self.stop_action = tool_bar.addAction(stop_icon, "Stop") self.stop_action.triggered.connect(self.player.stop) play_menu.addAction(self.stop_action) # Previous previous_icon = self.style().standardIcon( QtWidgets.QStyle.SP_MediaSkipBackward) self.previous_action = tool_bar.addAction(previous_icon, "Previous") self.previous_action.triggered.connect(self.previous_clicked) play_menu.addAction(self.previous_action) # Next next_icon = self.style().standardIcon( QtWidgets.QStyle.SP_MediaSkipForward) self.next_action = tool_bar.addAction(next_icon, "Next") self.next_action.triggered.connect(self.playlist.next) play_menu.addAction(self.next_action) # About menu about_menu = self.menuBar().addMenu("&About") about_qt_action = QtWidgets.QAction("About &Qt", self) about_menu.addAction(about_qt_action) # Create video widget self.video_widget = QtMultimediaWidgets.QVideoWidget() # Create widget that will contain all of the UI elements self.window_widget = QtWidgets.QWidget() self.setCentralWidget(self.window_widget) # add slider to control volume self.vol_slider = QtWidgets.QSlider() self.vol_slider.setOrientation(QtGui.Qt.Horizontal) self.vol_slider.setMinimum(0) self.vol_slider.setMaximum(100) self.vol_slider.setFixedWidth(120) self.vol_slider.setValue(self.player.volume()) self.vol_slider.setTickInterval(10) self.vol_slider.setTickPosition(QtWidgets.QSlider.TicksBelow) self.vol_slider.setToolTip("Volume") self.vol_slider.valueChanged.connect(self.player.setVolume) tool_bar.addSeparator() tool_bar.addWidget(self.vol_slider) tool_bar.addSeparator() # Split split_icon = self.style().standardIcon(QtWidgets.QStyle.SP_ArrowDown) self.split_action = tool_bar.addAction(split_icon, 'Split') self.split_action.triggered.connect(self.split) tool_bar.addSeparator() self.speed_slider = QtWidgets.QSlider() self.speed_slider.setOrientation(QtGui.Qt.Horizontal) self.speed_slider.setMinimum(0) self.speed_slider.setMaximum(200) self.speed_slider.setValue(100) self.speed_slider.setFixedWidth(120) self.speed_slider.setToolTip("Speed") self.speed_slider.valueChanged.connect(self.set_speed) self.speed_label = QtWidgets.QLabel(' ' + str(self.speed_slider.value() / 100) + 'x') tool_bar.addWidget(self.speed_slider) tool_bar.addWidget(self.speed_label) # BOTTOM STUFF # Time slider self.time_slider = QtWidgets.QSlider() self.time_slider.setOrientation(QtGui.Qt.Horizontal) self.time_slider.setRange(0, 0) # Empty layout to store all cuts self.cuts_layout = QtWidgets.QVBoxLayout() # Details under the slider self.time_details = QtWidgets.QHBoxLayout() self.current_label = QtWidgets.QLabel('') self.duration_label = QtWidgets.QLabel('') self.current_label.setFixedHeight(9) self.duration_label.setFixedHeight(9) self.time_details.addWidget(self.current_label) self.time_details.addStretch(1) self.time_details.addWidget(self.duration_label) # MAIN UI WINDOW LAYOUT self.main_layout = QtWidgets.QVBoxLayout() self.main_layout.addWidget(self.video_widget) self.main_layout.addWidget(self.time_slider) self.main_layout.addLayout(self.time_details) self.main_layout.addLayout(self.cuts_layout) self.window_widget.setLayout(self.main_layout) self.player.setPlaylist(self.playlist) self.player.stateChanged.connect(self.update_buttons) self.player.setVideoOutput(self.video_widget) self.update_buttons(self.player.state()) # Initialize duration and current (both represented in milliseconds) self.duration = 0 self.current = 0 self.cuts = [] self.player.positionChanged.connect(self.position_changed) self.time_slider.valueChanged.connect(self.set_position)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(917, 663) self.menu_widget = QtWidgets.QWidget(Form) self.menu_widget.setGeometry(QtCore.QRect(10, 10, 131, 641)) self.menu_widget.setObjectName("menu_widget") self.menu1_widget = QtWidgets.QWidget(self.menu_widget) self.menu1_widget.setGeometry(QtCore.QRect(4, 10, 121, 41)) self.menu1_widget.setObjectName("menu1_widget") self.menu_btn = QtWidgets.QPushButton(self.menu1_widget) self.menu_btn.setGeometry(QtCore.QRect(20, 10, 75, 23)) self.menu_btn.setObjectName("menu_btn") self.menu_btn.setCheckable(True) self.menu_btn.toggle() self.menu_btn.clicked.connect(self.menu_btn_clicked) self.menu2_widget = QtWidgets.QWidget(self.menu_widget) self.menu2_widget.setGeometry(QtCore.QRect(3, 70, 121, 111)) self.menu2_widget.setObjectName("menu2_widget") self.vid_btn = QtWidgets.QPushButton(self.menu2_widget) self.vid_btn.setGeometry(QtCore.QRect(20, 20, 75, 23)) self.vid_btn.setObjectName("vid_btn") self.vid_btn.setCheckable(True) self.vid_btn.toggle() self.vid_btn.clicked.connect(self.vid_btn_clicked) self.heat_btn = QtWidgets.QPushButton(self.menu2_widget) self.heat_btn.setGeometry(QtCore.QRect(20, 50, 75, 23)) self.heat_btn.setObjectName("heat_btn") self.heat_btn.setCheckable(True) self.heat_btn.toggle() self.heat_btn.clicked.connect(self.heat_btn_clicked) self.gridLayoutWidget = QtWidgets.QWidget(Form) self.gridLayoutWidget.setGeometry(QtCore.QRect(150, 10, 761, 641)) self.gridLayoutWidget.setObjectName("gridLayoutWidget") self.main_lay = QtWidgets.QGridLayout(self.gridLayoutWidget) self.main_lay.setContentsMargins(0, 0, 0, 0) self.main_lay.setObjectName("main_lay") self.vid_lay = QtWidgets.QGridLayout() self.vid_lay.setObjectName("vid_lay") self.vid_widget = QtWidgets.QWidget(self.gridLayoutWidget) self.vid_widget.setObjectName("vid_widget") self.video_widget = QtWidgets.QWidget(self.vid_widget) self.video_widget.setGeometry(QtCore.QRect(20, 110, 331, 331)) self.video_widget.setObjectName("video_widget") self.verticalLayoutWidget = QtWidgets.QWidget(self.vid_widget) self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 10, 371, 80)) self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") self.videoMenu_VLayout = QtWidgets.QVBoxLayout( self.verticalLayoutWidget) self.videoMenu_VLayout.setContentsMargins(0, 0, 0, 0) self.videoMenu_VLayout.setObjectName("videoMenu_VLayout") self.dateMenu_HLayout = QtWidgets.QHBoxLayout() self.dateMenu_HLayout.setObjectName("horizontalLayout") self.dateLabel = QtWidgets.QLabel(self.verticalLayoutWidget) self.dateLabel.setObjectName("dateLabel") self.dateMenu_HLayout.addWidget(self.dateLabel) self.dateEdit = QtWidgets.QDateEdit(self.verticalLayoutWidget) self.dateEdit.setObjectName("dateEdit") self.dateMenu_HLayout.addWidget(self.dateEdit) self.videoMenu_VLayout.addLayout(self.dateMenu_HLayout) self.timeLabel_HLayout = QtWidgets.QHBoxLayout() self.timeLabel_HLayout.setObjectName("horizontalLayout_2") self.timeLabel = QtWidgets.QLabel(self.verticalLayoutWidget) self.timeLabel.setObjectName("label_2") self.timeLabel_HLayout.addWidget(self.timeLabel) self.timeEdit_1 = QtWidgets.QTimeEdit(self.verticalLayoutWidget) self.timeEdit_1.setObjectName("timeEdit") self.timeLabel_HLayout.addWidget(self.timeEdit_1) self.timeEdit_2 = QtWidgets.QTimeEdit(self.verticalLayoutWidget) self.timeEdit_2.setObjectName("timeEdit_2") self.timeLabel_HLayout.addWidget(self.timeEdit_2) self.videoMenu_VLayout.addLayout(self.timeLabel_HLayout) self.total_videoBtn_HLayout = QtWidgets.QWidget(self.vid_widget) self.total_videoBtn_HLayout.setGeometry(QtCore.QRect(70, 460, 231, 80)) self.total_videoBtn_HLayout.setObjectName("videoBtn_HLayout") self.videoBtn_HLayout = QtWidgets.QHBoxLayout( self.total_videoBtn_HLayout) self.videoBtn_HLayout.setContentsMargins(0, 0, 0, 0) self.videoBtn_HLayout.setObjectName("horizontalLayout_3") self.playBtn = QtWidgets.QPushButton(self.total_videoBtn_HLayout) self.playBtn.setObjectName("playBtn") self.playBtn.clicked.connect(self.play_btn_clicked) self.videoBtn_HLayout.addWidget(self.playBtn) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.videoBtn_HLayout.addItem(spacerItem) self.stopBtn = QtWidgets.QPushButton(self.total_videoBtn_HLayout) self.stopBtn.setObjectName("pushButton_2") self.stopBtn.clicked.connect(self.stop_btn_clicked) self.videoBtn_HLayout.addWidget(self.stopBtn) self.vid_lay.addWidget(self.vid_widget, 0, 1, 1, 1) self.main_lay.addLayout(self.vid_lay, 0, 0, 1, 1) self.heat_lay = QtWidgets.QGridLayout() self.heat_lay.setObjectName("heat_lay") self.heat_widget = QtWidgets.QWidget(self.gridLayoutWidget) self.heat_widget.setObjectName("heat_widget") self.heat_label = QtWidgets.QLabel(self.heat_widget) self.heat_label.setGeometry(QtCore.QRect(10, 10, 56, 12)) self.heat_label.setObjectName("heat_label") self.time_check = QtWidgets.QCheckBox(self.heat_widget) self.time_check.setGeometry(QtCore.QRect(10, 33, 81, 16)) self.time_check.setObjectName("time_check") self.start_time = QtWidgets.QTimeEdit(self.heat_widget) self.start_time.setGeometry(QtCore.QRect(100, 30, 118, 22)) self.start_time.setObjectName("start_time") self.end_time = QtWidgets.QTimeEdit(self.heat_widget) self.end_time.setGeometry(QtCore.QRect(230, 30, 118, 22)) self.end_time.setObjectName("end_time") self.img_label = QtWidgets.QLabel(self.heat_widget) self.img_label.setGeometry(QtCore.QRect(10, 70, 56, 12)) self.img_label.setText("") self.img_label.setObjectName("img_label") self.heat_lay.addWidget(self.heat_widget, 0, 0, 1, 1) self.main_lay.addLayout(self.heat_lay, 0, 1, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) self.menu_mainPage() # video player widget self.vWidget = QtMultimediaWidgets.QVideoWidget(self.video_widget) self.vWidget.resize(self.video_widget.size()) # media area self.player = QtMultimedia.QMediaPlayer(self.video_widget) self.player.setMedia( QUrl.fromLocalFile("C:\\Users\\bit\\Downloads\\cctv_store.mp4")) self.player.setVideoOutput(self.vWidget)