diff -upr -x .svn DirectShowFilters - Kopie/TsReader/source/TsDuration.cpp DirectShowFilters/TsReader/source/TsDuration.cpp
--- DirectShowFilters - Kopie/TsReader/source/TsDuration.cpp	2011-01-29 23:40:11.411929600 +0100
+++ DirectShowFilters/TsReader/source/TsDuration.cpp	2011-01-30 00:08:57.850676300 +0100
@@ -40,7 +40,10 @@ CTsDuration::~CTsDuration(void)
 
 void CTsDuration::SetFileReader(FileReader* reader)
 {
-  m_reader=reader;
+  if (m_reader != reader) {
+    m_startPcr.Reset();
+    m_reader=reader;
+  }
 }
 
 void CTsDuration::Set(CPcr& startPcr, CPcr& endPcr, CPcr& maxPcr)
@@ -56,7 +59,10 @@ void CTsDuration::Set(CPcr& startPcr, CP
   
 void CTsDuration::SetVideoPid(int pid)
 {
-  m_videoPid=pid;
+  if (m_videoPid != pid) {
+    m_startPcr.Reset();
+    m_videoPid=pid;
+  }
 }
 
 int CTsDuration::GetPid()
@@ -69,7 +75,7 @@ int CTsDuration::GetPid()
 // Determines the total duration of the file (or timeshifting files)
 // 
 // 
-void CTsDuration::UpdateDuration()
+void CTsDuration::UpdateDuration(bool startreset)
 {
 
   byte buffer[32712];
@@ -81,12 +87,14 @@ void CTsDuration::UpdateDuration()
     m_bSearchStart=true;
     m_bSearchEnd=false;
     m_bSearchMax=false;
-    m_startPcr.Reset();
     m_maxPcr.Reset();
-    m_reader->SetFilePointer(0,FILE_BEGIN);
 
     Reset() ; // Reset internal "PacketSync" buffer
 
+    if (startreset) {
+      m_startPcr.Reset();
+      m_reader->SetFilePointer(0,FILE_BEGIN);
+    }
     //find the first pcr in the file
     while (!m_startPcr.IsValid)
     {
@@ -182,9 +190,6 @@ void CTsDuration::UpdateDuration()
     }
   }
 
-  //park filepointer at end of file
-  m_reader->SetFilePointer(-1,FILE_END);
-  m_reader->Read(buffer,1,&dwBytesRead);
 }
 
 void CTsDuration::OnTsPacket(byte* tsPacket)
diff -upr -x .svn DirectShowFilters - Kopie/TsReader/source/TsDuration.h DirectShowFilters/TsReader/source/TsDuration.h
--- DirectShowFilters - Kopie/TsReader/source/TsDuration.h	2011-01-29 23:40:11.463932600 +0100
+++ DirectShowFilters/TsReader/source/TsDuration.h	2011-01-30 00:10:02.454371400 +0100
@@ -11,7 +11,7 @@ public:
   virtual ~CTsDuration(void);
   void SetFileReader(FileReader* reader);
 	void OnTsPacket(byte* tsPacket);
-  void UpdateDuration();
+  void UpdateDuration(bool startreset);
   void SetVideoPid(int pid);
   int  GetPid();
   CRefTime Duration();      
diff -upr -x .svn DirectShowFilters - Kopie/TsReader/source/TsReader.cpp DirectShowFilters/TsReader/source/TsReader.cpp
--- DirectShowFilters - Kopie/TsReader/source/TsReader.cpp	2011-01-29 23:40:11.376927600 +0100
+++ DirectShowFilters/TsReader/source/TsReader.cpp	2011-01-30 00:12:34.528069500 +0100
@@ -632,6 +632,7 @@
 STDMETHODIMP CTsReaderFilter::Load(LPCOLESTR pszFileName,const AM_MEDIA_TYPE *pmt)
 {
   LogDebug("CTsReaderFilter::Load()");
+  ::SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);
   //clean up any old file readers
   if (m_fileReader != NULL)
     delete m_fileReader;
@@ -764,7 +765,7 @@
 
     //get file duration
     m_duration.SetFileReader(m_fileDuration);
-    m_duration.UpdateDuration();
+    m_duration.UpdateDuration(true);
 
     float milli = m_duration.Duration().Millisecs();
     milli /= 1000.0;
@@ -1136,6 +1137,7 @@
   int durationUpdateLoop = 1;
   long Old_rtspDuration = -1 ;
   long PauseDuration =0;
+  CTsDuration duration;
 
   ::SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_BELOW_NORMAL);
   do
@@ -1148,10 +1150,9 @@
     if (m_fileDuration!=NULL)
     {
       //no, then get the duration from the local file
-      CTsDuration duration;
       duration.SetFileReader(m_fileDuration);
       duration.SetVideoPid(m_duration.GetPid());
-      duration.UpdateDuration();
+      duration.UpdateDuration(false);
 
       //did we find a duration?
       if (duration.Duration().Millisecs()>0)
@@ -1244,7 +1245,7 @@
       }
     }
   }
-  while (!ThreadIsStopping(1000)) ;
+  while (!ThreadIsStopping(1500)) ;
   LogDebug("CTsReaderFilter::ThreadProc stopped()");
 }
 
diff -upr -x .svn DirectShowFilters - Kopie/TsWriter/source/DiskRecorder.cpp DirectShowFilters/TsWriter/source/DiskRecorder.cpp
--- DirectShowFilters - Kopie/TsWriter/source/DiskRecorder.cpp	2011-01-30 00:01:32.116181700 +0100
+++ DirectShowFilters/TsWriter/source/DiskRecorder.cpp	2011-01-30 00:13:22.772829000 +0100
@@ -359,6 +359,7 @@ void CDiskRecorder::Reset()
 		m_mapLastPtsDts.clear();
     m_iTsContinuityCounter=0;
 
+    ::SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);
 		//	Reset the write buffer throttle
 		LogDebug("CDiskRecorder::Reset() - Reset write buffer throttle");
 		m_iWriteBufferThrottle = 0;
diff -upr -x .svn DirectShowFilters - Kopie/TsWriter/source/FileWriter.cpp DirectShowFilters/TsWriter/source/FileWriter.cpp
--- DirectShowFilters - Kopie/TsWriter/source/FileWriter.cpp	2011-01-29 23:40:10.370870100 +0100
+++ DirectShowFilters/TsWriter/source/FileWriter.cpp	2011-01-30 00:16:12.126515400 +0100
@@ -136,6 +136,12 @@ HRESULT FileWriter::OpenFile()
 		return HRESULT_FROM_WIN32(dwErr);
 	}
 
+  DWORD cch;
+  if (!DeviceIoControl(m_hFile, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &cch, NULL))
+  {
+    LogDebug("DeviceIoControl: Couldn't set sparse - working without sparse");
+  }
+
 	SetFilePointer(0, FILE_END);
 	m_chunkReserveFileSize = GetFilePointer();
 	SetFilePointer(0, FILE_BEGIN);
@@ -176,14 +182,17 @@ DWORD FileWriter::SetFilePointer(__int64
 {
 	LARGE_INTEGER li;
 	li.QuadPart = llDistanceToMove;
-	return ::SetFilePointer(m_hFile, li.LowPart, &li.HighPart, dwMoveMethod);
+	return ::SetFilePointerEx(m_hFile, li, NULL, dwMoveMethod);
 }
 
 __int64 FileWriter::GetFilePointer()
 {
-	LARGE_INTEGER li;
+	LARGE_INTEGER li, llDistanceToMove;
 	li.QuadPart = 0;
-	li.LowPart = ::SetFilePointer(m_hFile, 0, &li.HighPart, FILE_CURRENT);
+  llDistanceToMove.QuadPart = 0;
+
+	::SetFilePointerEx(m_hFile, llDistanceToMove, &li, FILE_CURRENT);
+
 	return li.QuadPart;
 }
 
diff -upr -x .svn DirectShowFilters - Kopie/TsWriter/source/TsWriter.cpp DirectShowFilters/TsWriter/source/TsWriter.cpp
--- DirectShowFilters - Kopie/TsWriter/source/TsWriter.cpp	2011-01-30 00:01:32.315193100 +0100
+++ DirectShowFilters/TsWriter/source/TsWriter.cpp	2011-01-30 00:17:12.442965300 +0100
@@ -106,10 +106,10 @@ void LogDebug(const char *fmt, ...) 
 	{
     SYSTEMTIME systemTime;
     GetLocalTime(&systemTime);
-		fprintf(fp,"%02.2d-%02.2d-%04.4d %02.2d:%02.2d:%02.2d.%02.2d %s\n",
+		fprintf(fp,"%02.2d-%02.2d-%04.4d %02.2d:%02.2d:%02.2d.%02.2d [%x]%s\n",
 			systemTime.wDay, systemTime.wMonth, systemTime.wYear,
 			systemTime.wHour,systemTime.wMinute,systemTime.wSecond,systemTime.wMilliseconds,
-			logbuffer);
+			GetCurrentThreadId(),logbuffer);
 		fclose(fp);
     //::OutputDebugStringA(logbuffer);::OutputDebugStringA("\n");
 	}
