                     ppsvect.push(pps);
                 } else if (frame.type == 6) {
 
-					//unescape Emulation Prevention bytes
-					Nalu.unescapeStream(pes.data,frame.start,frame.start + frame.length);
-
-					// We already know it's 6, so skip first byte
-					pes.data.position = frame.start + 1;
-
-					// we need at least 12 bytes to retrieve Caption length
-					if(pes.data.bytesAvailable > 12) {
-
-						// get the SEI payload type
-						var payload_type : uint = 0;
-						var payload_size : uint = 0;
-						while (pes.data.position < frame.start + frame.length) {
-							// Parse payload type.
-							payload_type= 0;
-							do {
-								payload_type += pes.data.readUnsignedByte();
-							} while (payload_type == 0xFF);
-							// Parse payload size.
-							payload_size = 0;
-							do {
-								payload_size += pes.data.readUnsignedByte();
-							} while (pes.data.bytesAvailable!=0 && payload_size == 0xFF);
-							// Process the payload. We only support EIA-608 payloads currently.
-							if (payload_type == 4) {
-								readCC(pes);
-							} else {
-								pes.data.position+=payload_size;
-							}
-						}
-					}
+                    var sei : ByteArray = new ByteArray();
+                    pes.data.position = frame.start;
+                    pes.data.readBytes(sei, 0, frame.length);
+                    //unescape Emulation Prevention bytes
+                    sei.length = Nalu.unescapeStream(sei,0,sei.length);
+
+
+                    // We already know it's 6, so skip first byte
+                    sei.position = 1;
+                    try {
+                        // we need at least 12 bytes to retrieve Caption length
+                        if(sei.bytesAvailable > 12) {
+
+                            // get the SEI payload type
+                            var payload_type : uint = 0;
+                            var payload_size : uint = 0;
+                            while (sei.position < sei.length) {
+                                // Parse payload type.
+                                payload_type= 0;
+                                do {
+                                    payload_type += sei.readUnsignedByte();
+                                } while (payload_type == 0xFF);
+                                // Parse payload size.
+                                payload_size = 0;
+                                do {
+                                    payload_size += sei.readUnsignedByte();
+                                } while (sei.bytesAvailable!=0 && payload_size == 0xFF);
+                                // Process the payload. We only support EIA-608 payloads currently.
+                                if (payload_type == 4) {
+                                    readCC(sei,pes.pts);
+                                } else {
+                                    sei.position+=payload_size;
+                                }
+                            }
+                        }
+                    } catch(error : Error) {
+                        CONFIG::LOGGING {
+                            Log.debug("TS: SEI parsing error : " + error.message);
+                        }
+                    }
                 } else if (frame.type == 0) {
                     // report parsing error
                     if(_callback_error != null) {

							var size:uint = total * 3;

							// em_data, do we need? It's not used for anything, but it's there, so i need to pull it out
							var otherByte:uint = pes.data.readUnsignedByte();

							if (pes.data.bytesAvailable >= size)
							{
								// ByteArray for onCaptionInfo event
								var sei : ByteArray = new ByteArray();

								};

								// add a new FLVTag with the onCaptionInfo call
								var tag:FLVTag = new FLVTag(FLVTag.METADATA, pts, pts, false);

								var data : ByteArray = new ByteArray();
								data.objectEncoding = ObjectEncoding.AMF0;
