new Date(2009, 1, 1) represents the first of February 2009. Not the second of February nor the first of January. Why this stupidity?
Archive for April, 2009
Javascript’s stupid Date constructor
Wednesday, April 29th, 2009
GStreamer: accurate duration
Sunday, April 19th, 2009When decoding, for instance, a variable-bitrate MP3, gstreamer reported durations are, to say the least, estimates. I’ve tried to get a better result in a few ways. First off, some files yield a duration tag, but even if you’re lucky and it is there, there are no guaranties about precision. After that I tried seeking to the end (GST_SEEK_END) of the stream and querying the position, which gstreamer didn’t like. Finally, routing the audio into a fakesink, waiting for the end of stream and then querying for the position gives the right result. It’s not the prettiest method, but it works.
This is a Python script that prints the duration of a media to stdout.