Index: gstffmpegdec.c
===================================================================
RCS file: /cvs/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegdec.c,v
retrieving revision 1.110.2.2
diff -u -r1.110.2.2 gstffmpegdec.c
--- gstffmpegdec.c	27 Sep 2005 15:51:59 -0000	1.110.2.2
+++ gstffmpegdec.c	27 Sep 2005 19:01:01 -0000
@@ -53,7 +53,8 @@
   gboolean opened;
   union {
     struct {
-      gint width, height, fps, fps_base;
+      gint width, height;
+      gdouble fps, old_fps;
       enum PixelFormat pix_fmt;
     } video;
     struct {
@@ -417,8 +418,8 @@
     case CODEC_TYPE_VIDEO:
       ffmpegdec->format.video.width = 0;
       ffmpegdec->format.video.height = 0;
-      ffmpegdec->format.video.fps = 0;
-      ffmpegdec->format.video.fps_base = 0;
+      ffmpegdec->format.video.fps = -1;
+      ffmpegdec->format.video.old_fps = -1;
       ffmpegdec->format.video.pix_fmt = PIX_FMT_NB;
       break;
     case CODEC_TYPE_AUDIO:
@@ -473,6 +474,13 @@
     ffmpegdec->par = g_new0 (GValue, 1);
     gst_value_init_and_copy (ffmpegdec->par, par);
   }
+  if (gst_structure_has_field (structure, "framerate")) {
+    ffmpegdec->format.video.old_fps = ffmpegdec->format.video.fps;
+    gst_structure_get_double (structure, "framerate", &ffmpegdec->format.video.fps);
+  }else {
+    ffmpegdec->format.video.old_fps = ffmpegdec->format.video.fps;
+    ffmpegdec->format.video.fps = -1;
+  }
 
   /* do *not* draw edges */
   ffmpegdec->context->flags |= CODEC_FLAG_EMU_EDGE;
@@ -598,22 +606,18 @@
     case CODEC_TYPE_VIDEO:
       if (ffmpegdec->format.video.width == ffmpegdec->context->width &&
           ffmpegdec->format.video.height == ffmpegdec->context->height &&
-          ffmpegdec->format.video.fps == ffmpegdec->context->time_base.den &&
-          ffmpegdec->format.video.fps_base ==
-              ffmpegdec->context->time_base.num &&
+          ffmpegdec->format.video.fps == ffmpegdec->format.video.old_fps &&
 	  ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt)
         return TRUE;
-      GST_DEBUG ("Renegotiating video from %dx%d@%d/%dfps to %dx%d@%d/%dfps",
-          ffmpegdec->format.video.width, ffmpegdec->format.video.height,
-          ffmpegdec->format.video.fps, ffmpegdec->format.video.fps_base,
-          ffmpegdec->context->width, ffmpegdec->context->height,
-          ffmpegdec->context->time_base.den,
-          ffmpegdec->context->time_base.num);
+      GST_DEBUG ("Renegotiating video from %dx%d@%0.2ffps to %dx%d@%0.2ffps",
+		 ffmpegdec->format.video.width, ffmpegdec->format.video.height,
+		 ffmpegdec->format.video.old_fps,
+		 ffmpegdec->context->width, ffmpegdec->context->height,
+		 ffmpegdec->format.video.fps);
       ffmpegdec->format.video.width = ffmpegdec->context->width;
       ffmpegdec->format.video.height = ffmpegdec->context->height;
-      ffmpegdec->format.video.fps = ffmpegdec->context->time_base.den;
-      ffmpegdec->format.video.fps_base = ffmpegdec->context->time_base.num;
-      ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt;
+      ffmpegdec->format.video.old_fps = ffmpegdec->format.video.fps;
+      ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt;      
       break;
     case CODEC_TYPE_AUDIO:
       if (ffmpegdec->format.audio.samplerate ==
@@ -638,6 +642,15 @@
    * by the codec, which is more often correct).
    */
  if (caps) {
+   
+   /* if a demuxer provided a framerate then use it (#313970) */
+   if (ffmpegdec->format.video.fps != -1) {
+     gst_structure_set (gst_caps_get_structure (caps, 0),
+			"framerate", G_TYPE_DOUBLE, 
+			ffmpegdec->format.video.fps, 
+			NULL);     
+   }
+   
    if (ffmpegdec->context->sample_aspect_ratio.num &&
        ffmpegdec->context->sample_aspect_ratio.den) {
      GST_DEBUG ("setting ffmpeg provided pixel-aspect-ratio");
