--- a/ext/pango/gstbasetextoverlay.c
+++ b/ext/pango/gstbasetextoverlay.c
@@ -763,6 +763,7 @@ gst_base_text_overlay_negotiate (GstBaseTextOverlay * overlay)
   GstCaps *target;
   GstQuery *query;
   gboolean attach = FALSE;
+  guint index;
 
   GST_DEBUG_OBJECT (overlay, "performing negotiation");
 
@@ -780,8 +781,16 @@ gst_base_text_overlay_negotiate (GstBaseTextOverlay * overlay)
   }
 
   if (gst_query_find_allocation_meta (query,
-          GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, NULL))
+          GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, &index)) {
+    const GstStructure *params;
+
+    if (gst_query_parse_nth_allocation_meta (query, index, &params) && params) {
+      gst_structure_get_int (params, "width", &overlay->width);
+      gst_structure_get_int (params, "height", &overlay->height);
+    }
+
     attach = TRUE;
+  }
 
   overlay->attach_compo_to_buffer = attach;
 
