I can't wrap my head around that. There seem to be a lot of redundancy, and even if it is not called called more than ten times in the main loop, I still find it hard to swallow that it loops through the whole list at each invocation.
def get_file_info(f, stream, field):
discoverer = GstPbutils.Discoverer()
discoverer.connect('discovered', on_discovered)
info = discoverer.discover_uri(f)
for vinfo in info.get_video_streams():
ftype = (vinfo.get_stream_type_nick())
width = vinfo.get_width()
height = (format(vinfo.get_height()))
depth = (format(vinfo.get_depth()))
framerate = ('Frate: {}'.format(vinfo.get_framerate_num()))
bitrate = ('Brate: {}'.format(vinfo.get_max_bitrate()))
par = vinfo.get_par_num()
fname = vinfo.get_caps().to_string().split(',')[0]
if stream == 'video':
if field == 'duration':
return str(convert_time(info.get_duration(), 'hh:mm:ss'))
elif field == 'width':
return str(width)
elif field == 'height':
return str(height)
elif field == 'type':
return str(ftype)
elif field == 'depth':
return str(depth)
elif field == 'framerate':
return str(framerate)
elif field == 'bitrate':
return str(bitrate)
elif field == 'par':
return str(par)
elif field == 'name':
return str(par)
I read the lambda documentation, but can't seem to write a proper one, but I would sure like to.