diff --git a/ext/vorbis/gstvorbisdec.c b/ext/vorbis/gstvorbisdec.c
index 645c27d..a17056e 100644
--- a/ext/vorbis/gstvorbisdec.c
+++ b/ext/vorbis/gstvorbisdec.c
@@ -998,6 +998,54 @@ wrong_samples:
 }
 
 static GstFlowReturn
+vorbis_dec_handle_header_buffer (GstVorbisDec * vd, GstBuffer * buffer)
+{
+  ogg_packet *packet;
+  ogg_packet_wrapper packet_wrapper;
+
+  gst_ogg_packet_wrapper_from_buffer (&packet_wrapper, buffer);
+  packet = gst_ogg_packet_from_wrapper (&packet_wrapper);
+
+  return vorbis_handle_header_packet (vd, packet);
+}
+
+static GstFlowReturn
+vorbis_dec_handle_header_caps (GstVorbisDec * vd, GstBuffer * buffer)
+{
+  GstFlowReturn result = GST_FLOW_OK;
+  GstCaps *caps = GST_BUFFER_CAPS (buffer);
+  GstStructure *s = gst_caps_get_structure (caps, 0);
+  const GValue *array = gst_structure_get_value (s, "streamheader");
+
+  if (array) {
+    const GValue *value = NULL;
+    GstBuffer *buf = NULL;
+
+    /* initial header */
+    value = gst_value_array_get_value (array, 0);
+    buf = gst_value_get_buffer (value);
+    result = vorbis_dec_handle_header_buffer (vd, buf);
+
+    /* comment header */
+    if (result == GST_FLOW_OK) {
+      value = gst_value_array_get_value (array, 1);
+      buf = gst_value_get_buffer (value);
+      result = vorbis_dec_handle_header_buffer (vd, buf);
+    }
+
+    /* bitstream codebook header */
+    if (result == GST_FLOW_OK) {
+      value = gst_value_array_get_value (array, 2);
+      buf = gst_value_get_buffer (value);
+      result = vorbis_dec_handle_header_buffer (vd, buf);
+    }
+  } else
+    GST_DEBUG_OBJECT (vd, "No headers found in caps");
+
+  return result;
+}
+
+static GstFlowReturn
 vorbis_dec_decode_buffer (GstVorbisDec * vd, GstBuffer * buffer)
 {
   ogg_packet *packet;
@@ -1034,6 +1082,10 @@ vorbis_dec_decode_buffer (GstVorbisDec * vd, GstBuffer * buffer)
   } else {
     GstClockTime timestamp, duration;
 
+    /* try to find header in caps so we can initialize the decoder */
+    if (!vd->initialized)
+      (void) vorbis_dec_handle_header_caps (vd, buffer);
+
     timestamp = GST_BUFFER_TIMESTAMP (buffer);
     duration = GST_BUFFER_DURATION (buffer);
 
