import subprocess

def getLength(filename):
    result = subprocess.Popen(['ffprobe', filename], stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT)
return [x for x in result.stdout.readlines() if 'Duration' in x]
How to get the duration of a video in Python?