I have recently ventured out into dealing with audio and video related coding and i have limited knowledge about neither one of them.
It happens that i have a project that is dealing with mpeg-2 video now. Is there any python library that available out there to extract the duration of the mpeg-2 video itself?
I don't know any pure python implementations. But maybe the opencv bindings works for you:
import cv
cvcapture = cv.CaptureFromFile("movie.mpg")
cv.GetCaptureProperty(cvcapture,cv.CV_CAP_PROP_FRAME_COUNT)
Otherwise, maye you can use pyffmpeg. Beware: It is my experience that the frame count is often not very accurate. Opencv 2.6 works very well, but ealier versions gives sometimes just garbage.
Edit: Ah, sorry my mistake: This gives you the frame count only. For the duration: Multiply this with the frame rate:
cv.GetCaptureProperty(cvcapture,cv.CV_CAP_PROP_FPS)