# get video meta information
def get_meta(vidfile):
global proc
- meta = { 'frames': -1, 'duration':-1, 'fps':-1.0 }
+ meta = { 'frames': -1, 'duration':-1, 'fps':-1.0, 'nsubs': -1 }
if proc:
return meta, False
+ meta['nsubs'] = count_subss(vidfile)
# try ffprobe method
try:
cmd = cfg['ffprobe'] + ' -v error -select_streams v:0 -of json -count_packets'
rc = False
if proc:
return thinfo, rc
- # check for subtitle streams
- addss = cfg['addss']
- if addss >= 0:
- nstreams = count_subss(vidfile)
- if addss > nstreams - 1:
- eprint(1, 'ignoring invalid subtitle stream index:', addss)
- addss = -1
- else:
- eprint(2, 'including subtitle stream index:', addss)
# generate thumbnail images from video
pictemplate = '%08d.png'
cmd = cfg['ffmpeg'] + ' -loglevel info -hide_banner -y'
else: # iframe
cmd += ' -vf "select=eq(pict_type\,I)'
cmd += ',showinfo,scale=' + str(cfg['thumb_width']) + ':-1'
- if addss >= 0:
- cmd += ',subtitles=\'' + vidfile + '\':si=' + str(addss)
+ if thinfo['addss'] >= 0:
+ cmd += ',subtitles=\'' + vidfile + '\':si=' + str(thinfo['addss'])
cmd += '" -vsync vfr "' + os.path.join(thdir, pictemplate) + '"'
eprint(2, cmd)
ebuf = ''
if not cfg['reuse']:
if idx['width'] != thinfo['width']:
return False
+ if idx['nsubs'] != thinfo['nsubs']:
+ return False
+ if idx['addss'] != thinfo['addss']:
+ return False
if idx['method'] != thinfo['method']:
return False
if idx['method'] == 'skip':
'frames': -1,
'duration': -1,
'fps': -1,
+ 'nsubs': -1,
'start': cfg['start'],
'end': cfg['end'],
'count': 0,
elif cfg['method'] == 'customvf':
thinfo['customvf'] = cfg['customvf']
# set these here for neater ordering
+ thinfo['addss'] = cfg['addss']
thinfo['ffpreview'] = _FFPREVIEW_VERSION
thinfo['date'] = 0
thinfo['th'] = []
if not ok:
return None, False
thinfo.update(meta)
+ if thinfo['addss'] >= thinfo['nsubs']:
+ thinfo['addss'] = -1
if not cfg['force']:
chk = chk_idxfile(thinfo, thdir)
if chk: