Comskip 0.79 build 36: Added DVRCut output format (1 Viewer)

erik1958

Portal Pro
January 28, 2006
100
7
The source of dvrcut is on my server so feel free to start the debugger and find out why.
Or upload a 3GB dvr-ms file to my server and let me do the debugging, but that will take more time I guess.
 

judolphin

Portal Member
August 31, 2007
8
0
Home Country
United States of America United States of America
I went ahead and debugged since I didn't expect a response (thanks for responding though!)... Good news, I found the problem and it was pretty simple!

The issue never happened when I debugged, always happened when it was used live... so I figured there was a file handle/lock issue somewhere, and that the thread was acting more quickly than the file system. So I added a reference to System.Threading, and added a "Thread.Sleep(500);" at the end of the while loop, problem solved. You may want to integrate this, as there are a fair number of uses who have experienced the same thing I have. Thanks!

This is the new SBECutter.cs; I marked the two lines I added.

PHP:
/****************************************************************************
While the underlying libraries are covered by LGPL, this sample is released 
as public domain.  It is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE.  
*****************************************************************************/

using System;
using System.Runtime.InteropServices;
//*****ADDED THE FOLLOWING LINE*****
using System.Threading;

using DirectShowLib.SBE;

namespace DirectShowLib.Sample
{
	public class SBECutter : IDisposable
	{
    // SBE provide an utility object for cutting SBE files
    IStreamBufferRecComp recComp;

		public SBECutter()
		{
      // Create this object
      recComp = (IStreamBufferRecComp) new StreamBufferComposeRecording();
    }

    ~SBECutter()
    {
      Dispose();
    }

    public void Dispose()
    {
      // Realease it
      if (recComp != null)
        Marshal.ReleaseComObject(recComp);

      GC.SuppressFinalize(this);
    }

    public void DoCut(string srcFile, string dstFile, int cnt, TimeSpan[] start, TimeSpan [] stop)
    {
      int hr = 0;

      // Initialize a destination file with the same profil as source file
      hr = recComp.Initialize(dstFile, srcFile);
      DsError.ThrowExceptionForHR(hr);

      // Copy source file into destination file
      int i = 0;
      while (i < cnt)
      {
          hr = recComp.AppendEx(srcFile, start[i].Ticks, stop[i].Ticks);
          DsError.ThrowExceptionForHR(hr);
          i++;
          //*****ADDED THE FOLLOWING LINE*****
          Thread.Sleep(500); //Prevents application from hanging when handling large files.
      }
      // Close destination file
      hr = recComp.Close();
      DsError.ThrowExceptionForHR(hr);
    }

  }
}
 

erik1958

Portal Pro
January 28, 2006
100
7
Nice!, thanks.
As I no longer have the CS development environment (I am a plain old C guy), can someone compile an updated DVRCut for me?
 

Users who are viewing this thread

Top Bottom