After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 640483 - flvdemux: Video's width, height and/or framerate src caps added when present on onMetaData
flvdemux: Video's width, height and/or framerate src caps added when present ...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
0.10.25
Other Linux
: Normal minor
: 0.10.29
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-01-24 22:38 UTC by Leonardo Sandoval
Modified: 2011-04-12 09:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Video's width, height and/or framerate src caps added when present on onMetaData (2.36 KB, patch)
2011-01-24 22:38 UTC, Leonardo Sandoval
none Details | Review
fix of first posted patch: framerate is now considered as a fraction. (2.97 KB, patch)
2011-01-25 18:51 UTC, Leonardo Sandoval
committed Details | Review

Description Leonardo Sandoval 2011-01-24 22:38:48 UTC
Created attachment 179243 [details] [review]
Video's width, height and/or framerate src caps added when present on onMetaData

this is a simple patch which adds videos width, height and framerate if these values are present on the flv metadata (on the 'onMetaData' tag). 

This information is valuable in the sense that no extra parsing has to be done on the bitstream data in order to extract the mentioned values.
Comment 1 Leonardo Sandoval 2011-01-25 18:41:14 UTC
Comment on attachment 179243 [details] [review]
Video's width, height and/or framerate src caps added when present on onMetaData

From e04428c2e0ed520cbb6c903ea22c17e49caac028 Mon Sep 17 00:00:00 2001
From: Leonardo Sandoval <lsandoval@ti.com>
Date: Mon, 24 Jan 2011 15:45:28 -0600
Subject: [PATCH] flvdemux: Video's width, height and framerate src caps added when present on onMetaData

---
 gst/flv/gstflvdemux.c |   37 +++++++++++++++++++++++++++++++++++++
 gst/flv/gstflvdemux.h |    1 +
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/gst/flv/gstflvdemux.c b/gst/flv/gstflvdemux.c
index 27796ea..cffa68c 100644
--- a/gst/flv/gstflvdemux.c
+++ b/gst/flv/gstflvdemux.c
@@ -278,6 +278,12 @@ gst_flv_demux_parse_metadata_item (GstFlvDemux * demux, GstByteReader * reader,
       } else if (!strcmp (tag_name, "AspectRatioY")) {
         demux->par_y = d;
         demux->got_par = TRUE;
+      } else if (!strcmp (tag_name, "width")) {
+        demux->w = d;
+      } else if (!strcmp (tag_name, "height")) {
+        demux->h = d;
+      } else if (!strcmp (tag_name, "framerate")) {
+        demux->framerate = d;
       } else {
         GST_INFO_OBJECT (demux, "Tag \'%s\' not handled", tag_name);
       }
@@ -1004,6 +1010,36 @@ gst_flv_demux_video_negotiate (GstFlvDemux * demux, guint32 codec_tag)
   gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION,
       demux->par_x, demux->par_y, NULL);
 
+  if (G_LIKELY (demux->w)) {
+    gst_caps_set_simple (caps, "width", G_TYPE_INT, demux->w, NULL);
+  }
+
+  if (G_LIKELY (demux->h)) {
+    gst_caps_set_simple (caps, "height", G_TYPE_INT, demux->h, NULL);
+  }
+
+  if (G_LIKELY (demux->framerate)) {
+    GValue fps_double = { 0, };
+    GValue fps_fraction = { 0, };
+    gint num = 0;
+    gint den = 0;
+
+    g_value_init (&fps_double, G_TYPE_DOUBLE);
+    g_value_init (&fps_fraction, GST_TYPE_FRACTION);
+    g_value_set_double (&fps_double, demux->framerate);
+    g_value_transform (&fps_double, &fps_fraction);
+    num = gst_value_get_fraction_numerator (&fps_fraction);
+    den = gst_value_get_fraction_denominator (&fps_fraction);
+
+    GST_DEBUG ("fps to be used on caps %f ( as a fraction = %d/%d)",
+        demux->framerate, num, den);
+
+    gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, num, den, NULL);
+
+    g_value_unset (&fps_double);
+    g_value_unset (&fps_fraction);
+  }
+
   if (demux->video_codec_data) {
     gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER,
         demux->video_codec_data, NULL);
@@ -1524,6 +1560,7 @@ gst_flv_demux_cleanup (GstFlvDemux * demux)
   gst_segment_init (&demux->segment, GST_FORMAT_TIME);
 
   demux->w = demux->h = 0;
+  demux->framerate = 0.0;
   demux->par_x = demux->par_y = 1;
   demux->video_offset = 0;
   demux->audio_offset = 0;
diff --git a/gst/flv/gstflvdemux.h b/gst/flv/gstflvdemux.h
index dadff94..106deae 100644
--- a/gst/flv/gstflvdemux.h
+++ b/gst/flv/gstflvdemux.h
@@ -109,6 +109,7 @@ struct _GstFlvDemux
   gboolean got_par;
   GstBuffer * video_codec_data;
   GstClockTime video_start;
+  gdouble framerate;
 
   gboolean random_access;
   gboolean need_header;
-- 
1.7.1
Comment 2 Leonardo Sandoval 2011-01-25 18:51:02 UTC
Created attachment 179310 [details] [review]
fix of first posted patch: framerate is now considered as a fraction.

there was an error in the first posted patch. This patch takes into account the (source cap) framerate as a fraction, not as a integer, so the exact fps value is constructed.
Comment 3 Mark Nauwelaerts 2011-04-12 09:08:38 UTC
Thanks.  Committed.

commit 071b90059f899669c7333487b2e61fe06631c8de
Author: Leonardo Sandoval <lsandoval@ti.com>
Date:   Mon Jan 24 15:45:28 2011 -0600

    flvdemux: add width, height and framerate to caps when present on onMetaData
    
    Fixes #640483.