 
 		public static function isTagAVCC(tag:FLVTagVideo):Boolean
 		{
+			if(!tag)
+				return false;
+
 			// Must be keyframe.
 			if(tag.frameType != FLVTagVideo.FRAME_TYPE_KEYFRAME)
 				return false;
 
-			// And config record.
-			if(tag.data[12] == 0)
-				return true;
-
-			return false;
+			// If config record, then it's an AVCC!
+			return tag.avcPacketType == 0;
 		}
 
 
 		public static function isTagIFrame(tag:FLVTagVideo):Boolean
 		{
+			if(!tag)
+				return false;
+
 			// Must be keyframe.
 			if(tag.frameType != FLVTagVideo.FRAME_TYPE_KEYFRAME)
 				return false;
 
-			// But not config record.
-			if(tag.data[12] == 0)
-				return false;
-
-			// It's an I-frame!
-			return true;
+			// It's an I-frame if not a config record!
+			return tag.avcPacketType == 1;
 		}
 
 		private function onBufferTag(tag:FLVTag):Boolean

				// Do writing.
				CONFIG::LOGGING
				{
					logger.debug("Writing tag " + buffer.length + " bytes @ " + lastWrittenTime + "sec type=" + tag.tagType);
				}

				if(writeToMasterBuffer)

				var header:FLVHeader = new FLVHeader();
				var headerBytes:ByteArray = new ByteArray();
				header.write(headerBytes);
				if(writeToMasterBuffer)
					_masterBuffer.writeBytes(headerBytes);
				appendBytes(headerBytes);

				flushPendingTags();
