GNOME Bugzilla – Bug 536472
mpeg2dec reports wrong video/audio length
Last modified: 2011-05-19 07:42:12 UTC
Please describe the problem: for inspecting media files I use gst-python's gst.extend.discoverer, which works pretty well on most media files, but with mpeg1/2 files I get different durations nearly every time. The time diff affects video as well as audio length and the diff is up to 3s with a small 30s file. happens on my current Debian/sid installation with gstreamer-0.10.19 gst-plugins-ugly 0.10.8 gst-python 0.10.11 mpeg2dec 0.4.1 as well as some older installations I was able to test Steps to reproduce: # discoverer stress test import sys import gobject gobject.threads_init() import gst from gst.extend.discoverer import Discoverer i = 0 min_vlength = gobject.G_MAXLONG min_alength = gobject.G_MAXLONG max_vlength = 0L max_alength = 0L def finished(d, result): global i global min_vlength, max_vlength global min_alength, max_alength min_alength = min(min_alength, d.audiolength) max_alength = max(max_alength, d.audiolength) min_vlength = min(min_vlength, d.videolength) max_vlength = max(max_vlength, d.videolength) print 'A: %d V: %d' % (d.audiolength, d.videolength) i += 1 if i >= 100: print 'MIN A: %s MIN V: %s' % (gst.TIME_ARGS(min_alength), gst.TIME_ARGS(min_vlength)) print 'MAX A: %s MAX V: %s' % (gst.TIME_ARGS(max_alength), gst.TIME_ARGS(max_vlength)) loop.quit() else: del d d = Discoverer(filename) d.connect('discovered', finished) d.discover() filename = sys.argv[1] d = Discoverer(filename) d.connect('discovered', finished) d.discover() loop = gobject.MainLoop() loop.run() Actual results: Expected results: Does this happen every time? Other information:
Created attachment 112070 [details] a small stress test
This might be caused by the way the duration for mpeg1/2 videos is calculated. It's just an interpolation by the (to that time known) average bitrate and total file length. So maybe the times when the discoverer finishes are slightly different and sometimes more buffers are processed already giving a more appropiate duration. Not sure what can be done about this bug, you won't get exact durations in any case but maybe the discoverer could be improved a bit to give at least consistent results...
http://movies.archive.bibalex.org/3562.mpg For this movie, Totem reports 12 minutes whereas the actual length is 43 minutes. I suppose that's related to this bug...?
I'll close this as WONTFIX now. Getting correct durations for MPEG1/2 videos is impossible unless you parse the complete file.