Cleaner code for ffprobe and avprobe backends
Better detection of duration when using ffprobe or avprobe
This commit is contained in:
parent
ac784e354f
commit
7f33af96aa
3 changed files with 52 additions and 73 deletions
|
|
@ -338,4 +338,53 @@ class executor(GObject.GObject):
|
|||
text=text.replace('>','>')
|
||||
text=text.replace('"','"')
|
||||
text=text.replace("'",''')
|
||||
return text
|
||||
return text
|
||||
|
||||
|
||||
def get_division(self,data):
|
||||
|
||||
pos = data.find("/")
|
||||
pos2 = data.find(":")
|
||||
|
||||
if (pos == -1):
|
||||
pos = pos2
|
||||
|
||||
if (pos == -1):
|
||||
try:
|
||||
return float(data)
|
||||
except:
|
||||
return 0
|
||||
else:
|
||||
try:
|
||||
data1 = float(data[:pos])
|
||||
data2 = float(data[pos+1:])
|
||||
except:
|
||||
return 0
|
||||
if (data2 == 0):
|
||||
return 0
|
||||
else:
|
||||
return (float(int((data1 / data2)*1000.0)))/1000.0
|
||||
|
||||
|
||||
def get_time(self,line):
|
||||
|
||||
time_string = ""
|
||||
|
||||
for letter in line.strip():
|
||||
if (letter == ':') or (letter == '.') or (letter.isdigit()):
|
||||
time_string += letter
|
||||
else:
|
||||
break
|
||||
|
||||
elements = time_string.split(":")
|
||||
|
||||
if (len(elements) == 0):
|
||||
return -1
|
||||
|
||||
value = 0
|
||||
for element in elements:
|
||||
if (element == ''):
|
||||
continue
|
||||
value *= 60
|
||||
value += int(0.5 + float(element))
|
||||
return value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue