         private var keyFrame:Boolean = false;
         private var totalAppended:int = 0;
 
+        // State used to estimate video framerate.
+        public var videoLastDTS:int = int.MIN_VALUE;
+
         public function clear(clearAACConfig:Boolean = false):void
         {
             if(clearAACConfig)
                 _aacConfig = null;
             _aacRemainder = null;
             _aacTimestamp = 0;
+
+            bufferedTagData.length = 0;
+            bufferedTagTimestamp.length = 0;
+            bufferedTagDuration.length = 0;
+
+            videoLastDTS = int.MIN_VALUE;
         }
 
         protected var sendingDebugEvents:Boolean = false;
 
-        private function sendFLVTag(flvts:int, type:uint, codec:int, mode:int, bytes:ByteArray, offset:uint, length:uint, duration:uint, buffer:Boolean = true):void
+        private function sendFLVTag(flvts:int, type:uint, codec:int, mode:int, bytes:ByteArray, offset:uint, length:uint, duration:int, buffer:Boolean = true):void
         {
             var tag:ByteArray = new ByteArray();
             

            naluProcessor.resetAVCCExtraction();
        }

        // State used to estimate video framerate.
        public var videoLastDTS:int = -1000000.0;

        /**
         * Convert and emit AVC NALU data.
         */

                
                if(sampleRate)
                {
                    var flvts:int = convertFLVTimestamp(timestamp + timeAccumulation);
                    
                    sendAACConfigFLVTag(flvts, profile, sampleRateIndex, channelConfig);
                    //logger.debug("Sending AAC @ " + flvts + " ts=" + timestamp + " acc=" + timeAccumulation);
