detect video length in seconds

Tim Roberts timr at probo.com
Wed May 3 02:41:44 EDT 2006


"garylinux at gmail.com" <garylinux at gmail.com> wrote:
>
>Is there a way to get the length of a video clip (divix/xvid) in
>seconds?

This is non-trivial.  MPEG files do not have an index, so the only way to
figure this out is to scan from the front of the file until you find a
timestamp, then scan backwards from the end of the file until you find a
timestamp, and subtract.

You can also try to extract the bitrate from an early header and use
arithmetic to get a good estimate.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list