Skip to content

Commit

Permalink
Fix issue when playblasted file is not available to read
Browse files Browse the repository at this point in the history
  • Loading branch information
sowwic committed Jul 28, 2020
1 parent b5e43c3 commit b040b77
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# dsPlayblast
Playblast to mp4

2 changes: 2 additions & 0 deletions dsPlayblast/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__ = "1.0.0"
__author__ = "Dmitrii Shevchenko"
3 changes: 3 additions & 0 deletions dsPlayblast/ffmpegFn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import time
import logging

LOGGER = logging.getLogger()
Expand All @@ -13,5 +14,7 @@ def __init__(self, ffmpeg_path: str, input_path: str, output_path: str = ""):
def convert_avi_to_mp4(self):
if not self.output_path or not self.output_path.endswith(".mp4"):
self.output_path = self.input_path.replace(".avi", ".mp4")
LOGGER.debug(f"File access: {os.access(self.input_path, mode=os.X_OK)}")
time.sleep(2)
command = f'"{self.ffmpeg_path}" -i {self.input_path} {self.output_path} -y'
return os.system(command)
2 changes: 1 addition & 1 deletion dsPlayblast/loggingFn.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def setup_logging():
brief_formatter = logging.Formatter(fmt="%(levelname)s | %(message)s", datefmt="%Y-%m-%d %H:%M")
verbose_formatter = logging.Formatter(fmt="%(asctime)s | %(levelname)s | %(name)s | %(message)s")
# Handlers
rfile_handler = logging.handlers.RotatingFileHandler(log_file, mode="a", maxBytes=1024, backupCount=1, delay=0)
rfile_handler = logging.handlers.RotatingFileHandler(log_file, mode="a", maxBytes=1024, backupCount=0, delay=0)
rfile_handler.setLevel("DEBUG")
rfile_handler.setFormatter(verbose_formatter)
stream_handler = logging.StreamHandler()
Expand Down
Empty file removed dsPlayblast/playblastFn.py
Empty file.
16 changes: 13 additions & 3 deletions dsPlayblast/playblastUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import webbrowser
from PySide2 import QtWidgets
from PySide2 import QtCore
from dsPlayblast import __version__
from dsPlayblast import __author__
from dsPlayblast import ffmpegFn
from dsPlayblast import widgets
from dsPlayblast import clientFn

__version__ = 1.0

LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -100,6 +100,7 @@ def create_actions(self):
self.always_on_top_action.setChecked(self.settings.value("always_on_top", 0))
self.ffmpeg_help_action = QtWidgets.QAction("FFmpeg download", self)
self.ffmpeg_help_action.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_DialogHelpButton))
self.about_help_action = QtWidgets.QAction("About", self)

# Create menus
self.options_menu = self.menuBar().addMenu("&Options")
Expand All @@ -108,6 +109,7 @@ def create_actions(self):

self.help_menu = self.menuBar().addMenu("Help")
self.help_menu.addAction(self.ffmpeg_help_action)
self.help_menu.addAction(self.about_help_action)

def create_widgets(self):
self.main_widget = QtWidgets.QWidget()
Expand Down Expand Up @@ -180,7 +182,7 @@ def create_widgets(self):

# Status bar
# self.statusBar = QtWidgets.QStatusBar()
self.statusBar = widgets.StatusLogger(level="DEBUG", timeout=4000)
self.statusBar = widgets.StatusLogger(level="INFO", timeout=4000)
self.statusBar.setFormatter(LOGGER.parent.handlers[0].formatter)
self.statusBar.widget.setMaximumHeight(17)
LOGGER.addHandler(self.statusBar)
Expand Down Expand Up @@ -232,6 +234,7 @@ def create_connections(self):
self.always_on_top_action.toggled.connect(self.toggle_always_on_top)
self.set_maya_port_action.triggered.connect(self.set_maya_port)
self.ffmpeg_help_action.triggered.connect(self.open_ffmpeg_web)
self.about_help_action.triggered.connect(self.diplay_about_info)

# Inputs
self.ffmpeg_path.path_line_edit.textChanged.connect(self.validate_paths)
Expand All @@ -251,6 +254,13 @@ def toggle_always_on_top(self) -> None:
def open_ffmpeg_web(self):
webbrowser.open(url="https://ffmpeg.org/", new=2, autoraise=True)

@QtCore.Slot()
def diplay_about_info(self):
info_dialog = QtWidgets.QMessageBox(self)
info_dialog.setWindowTitle("About")
info_dialog.setText(f"Author: {__author__}\nVersion: {__version__}")
info_dialog.exec_()

@ QtCore.Slot()
def connect_to_maya(self) -> None:
LOGGER.info(f"TODO: Connecting to maya port {self.maya_client.port}")
Expand Down
7 changes: 5 additions & 2 deletions dsPlayblast/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ def __init__(self, parent=None, mode=0, start_time=0, end_time=120, max_time=999
# Widgets
self.timeslider_radio = QtWidgets.QRadioButton("Time slider")
self.startend_radio = QtWidgets.QRadioButton("Start/end")
self.timeslider_radio.setChecked(not mode)
self.startend_radio.setChecked(mode)
self.timeslider_radio.setChecked(mode)
self.startend_radio.setChecked(not mode)

self.start_label = QtWidgets.QLabel("Start:")
self.start_time = QtWidgets.QSpinBox()
self.start_time.setMinimumWidth(50)
Expand Down Expand Up @@ -273,6 +274,8 @@ def __init__(self, parent=None, mode=0, start_time=0, end_time=120, max_time=999
self.main_layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.main_layout)

# Apply selection

self.startend_radio.toggled.connect(self.set_spinboxes_enabled)

def showEvent(self, event):
Expand Down

0 comments on commit b040b77

Please sign in to comment.