public void StopWriting()
 {
     lock(lockObject)
     {
         if (writer != null)
         {
             isWriting = false;
             writer.Close();
             writer = null;
         }
     }
 }
        public bool OpenWriteStream(String fileName, int codec, int fps, int width, int height, bool isColour)
        {
            isWriting= false;
            try
            {
                writer = new ImageStreamWriter(fileName, codec, fps, width, height, isColour);
                isWriting = true;
                frameWriterCount = 0;
            }
            catch (Exception e)
            {
                isWriting = false;
            }

            return isWriting;
        }