views:

67

answers:

1

hi folks, i need to get the video duration in python (django), the video formats that i need to get are mp4, flv, avi, mov... I have a shared hosting so i have no ffmpeg support.

Thanks!

sorry for my english.

+3  A: 

You'll probably need to invoke an external program, ffprobe can provide you with that information

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]
TokenMacGuy
+1 I've had to do this before, and unless you want to write ad-hoc parsers for all those container formats yourself, you're much better off using an external program.
Doug
ffmpeg is pretty much `<insert deity name here>`
TokenMacGuy