Index: matroska-mux.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/gst/matroska/matroska-mux.c,v
retrieving revision 1.52
diff -u -p -r1.52 matroska-mux.c
--- matroska-mux.c	24 Dec 2006 11:24:59 -0000	1.52
+++ matroska-mux.c	17 Dec 2007 17:14:22 -0000
@@ -541,15 +541,14 @@ gst_matroska_mux_video_pad_setcaps (GstP
   /* get general properties */
   gst_structure_get_int (structure, "width", &width);
   gst_structure_get_int (structure, "height", &height);
-  framerate = gst_structure_get_value (structure, "framerate");
-  if (framerate == NULL || !GST_VALUE_HOLDS_FRACTION (framerate))
-    return FALSE;
-
   videocontext->pixel_width = width;
   videocontext->pixel_height = height;
-  context->default_duration = gst_util_uint64_scale_int (GST_SECOND,
-      gst_value_get_fraction_denominator (framerate),
-      gst_value_get_fraction_numerator (framerate));
+  framerate = gst_structure_get_value (structure, "framerate");
+  if (framerate != NULL && GST_VALUE_HOLDS_FRACTION (framerate)) {
+    context->default_duration = gst_util_uint64_scale_int (GST_SECOND,
+        gst_value_get_fraction_denominator (framerate),
+        gst_value_get_fraction_numerator (framerate));
+  }
 
   if (gst_structure_get_fraction (structure, "pixel-aspect-ratio",
           &pixel_width, &pixel_height)) {
@@ -1176,6 +1175,10 @@ gst_matroska_mux_release_pad (GstElement
     GstMatroskaPad *collect_pad = (GstMatroskaPad *) cdata;
 
     if (cdata->pad == pad) {
+      if (!collect_pad->duration) {
+        collect_pad->duration = GST_CLOCK_DIFF (collect_pad->first_timestamp,
+                                                collect_pad->last_timestamp);
+      }
       if (collect_pad->duration > mux->duration)
         mux->duration = collect_pad->duration;
       gst_matroska_pad_free (collect_pad);
@@ -1603,6 +1606,10 @@ gst_matroska_mux_finish (GstMatroskaMux 
 
     collect_pad = (GstMatroskaPad *) collected->data;
 
+    if (!collect_pad->duration) {
+      collect_pad->duration = GST_CLOCK_DIFF (collect_pad->first_timestamp,
+                                              collect_pad->last_timestamp);
+    }
     if (collect_pad->duration > duration)
       duration = collect_pad->duration;
   }
@@ -1921,6 +1928,10 @@ gst_matroska_mux_collected (GstCollectPa
     GST_DEBUG_OBJECT (best->collect.pad, "best pad");
 
     /* write one buffer */
+    best->last_timestamp = GST_BUFFER_TIMESTAMP (best->buffer);
+    if (G_UNLIKELY (!best->first_timestamp)) {
+      best->first_timestamp = best->last_timestamp;
+    }
     ret = gst_matroska_mux_write_data (mux, best);
   } while (ret == GST_FLOW_OK && !popped);
 
Index: matroska-mux.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/gst/matroska/matroska-mux.h,v
retrieving revision 1.13
diff -u -p -r1.13 matroska-mux.h
--- matroska-mux.h	15 Nov 2006 12:08:20 -0000	1.13
+++ matroska-mux.h	17 Dec 2007 17:14:22 -0000
@@ -76,6 +76,8 @@ typedef struct
   GstBuffer *buffer;            /* the queued buffer for this pad */
 
   guint64 duration;
+  GstClockTime first_timestamp;
+  GstClockTime last_timestamp;
 }
 GstMatroskaPad;
 
