17 lines
503 B
Python
17 lines
503 B
Python
import re
|
|
import subprocess
|
|
|
|
|
|
def get_video_real_duration(filename):
|
|
ffmpeg_process = subprocess.Popen([
|
|
"ffmpeg", "-hide_banner", "-i", filename, "-c", "copy", "-f", "null", "-"
|
|
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
result = "0:0:0.0"
|
|
for line in ffmpeg_process.stderr.readlines():
|
|
match_result = re.findall("(?<= time=).+?(?= )", line.decode())
|
|
if len(match_result) == 0:
|
|
continue
|
|
result = match_result.pop()
|
|
return result
|
|
|