--- a/gst/h264parse/gsth264parse.c	2011-06-20 16:47:23.412712699 +0100
+++ b/gst/h264parse/gsth264parse.c	2011-06-20 17:05:07.319735600 +0100
@@ -1128,11 +1128,22 @@ gst_h264_parse_make_codec_data (GstH264P
       num_sps++;
       /* size bytes also count */
       sps_size += GST_BUFFER_SIZE (nal) - 4 + 2;
+
       if (GST_BUFFER_SIZE (nal) >= 7) {
-        found = TRUE;
-        profile_idc = (GST_BUFFER_DATA (nal))[4];
-        profile_comp = (GST_BUFFER_DATA (nal))[5];
-        level_idc = (GST_BUFFER_DATA (nal))[6];
+        guint8 *nal_data = GST_BUFFER_DATA (nal);
+        /* Handle 4 byte start codes */
+        if ((nal_data[0] == 0) && (nal_data[1] == 0) && (nal_data[2] == 0) &&
+             (GST_BUFFER_SIZE (nal) >= 8)) {
+          found = TRUE;
+          profile_idc = (GST_BUFFER_DATA (nal))[5];
+          profile_comp = (GST_BUFFER_DATA (nal))[6];
+          level_idc = (GST_BUFFER_DATA (nal))[7];
+        } else {
+          found = TRUE;
+          profile_idc = (GST_BUFFER_DATA (nal))[4];
+          profile_comp = (GST_BUFFER_DATA (nal))[5];
+          level_idc = (GST_BUFFER_DATA (nal))[6];
+        }
       }
     }
   }
