thdir = None
cur = 0
_dbg_num_tlabels = 0
+ view_locked = False
def __new__(cls, *args, title='', **kwargs):
if cls._instance is None:
menu.exec_(self.mapToGlobal(pos))
def manage_thumbs(self, outdir):
+ if self.view_locked:
+ return
dlg = tmDialog(self, odir=cfg['outdir'])
res = dlg.exec_()
if res == QDialog.Accepted:
self.load_view(lfile)
def _play_video(self, ts=None, paused=False):
+ if self.view_locked:
+ return
if ts is None:
if len(self.tlabels) < 1:
return
return tlabels
def load_view(self, fname):
+ if self.view_locked:
+ return
+ self.view_locked = True
# sanitize file name
if not fname:
fname = os.getcwd()
fname, _ = QFileDialog.getOpenFileName(self, 'Open File', fname,
'Video Files (*.avi *.mkv *.mp4);;All Files (*)', options=options)
if not fname or not os.path.exists(fname) or not os.access(fname, os.R_OK):
+ self.view_locked = False
return
self.fname = os.path.abspath(fname)
self.vfile = os.path.basename(self.fname)
self.thinfo, ok = get_thinfo(self.fname, self.thdir)
if self.thinfo is None:
self.statdsp[0].setText('Unrecognized file format')
+ self.view_locked = False
return
if not ok:
# (re)generate thumbnails and index file
self.calculate_props()
self.setMinimumSize(self.tlwidth + self.px, self.tlheight + self.py)
self.optimize_extent()
+ self.view_locked = False
############################################################
def get_meta(vidfile):
global proc
meta = { 'frames': -1, 'duration':-1, 'fps':-1.0 }
+ if proc:
+ return meta, False
# try ffprobe method
try:
cmd = cfg['ffprobe'] + ' -v error -select_streams v:0 -of json -count_packets'
eprint(1, stderr.decode())
except Exception as e:
eprint(0, cmd + '\n failed: ' + str(e))
+ if proc:
+ proc.wait()
+ proc = None
# ffprobe didn't cut it, try ffmpeg instead
try:
cmd = cfg['ffmpeg'] + ' -nostats -i "' + vidfile + '"'
eprint(1, stderr.decode())
except Exception as e:
eprint(0, cmd + '\n failed: ' + str(e))
+ if proc:
+ proc.wait()
+ proc = None
return meta, False
# extract thumbnails from video and collect timestamps
def make_thumbs(vidfile, thinfo, thdir, prog_cb=None):
global proc
rc = False
+ if proc:
+ return thinfo, rc
pictemplate = '%08d.png'
cmd = cfg['ffmpeg'] + ' -loglevel info -hide_banner -y'
if cfg['start']:
rc = True
except Exception as e:
eprint(0, cmd + '\n failed: ' + str(e))
+ if proc:
+ proc.wait()
+ proc = None
return thinfo, rc
# open video in player