How to start capture without stopping preview (separate capture) in console application in Video Capture SDK .Net?

Related products
Video Capture SDK .Net

Sample code

C# sample code, that demonstrate usage:
private async static void TestVideoCapture()
{
  string outputFolder = @"c:\test";

  VideoCaptureCore capture = new VideoCaptureCore();

  capture.Video_CaptureDevice = new VideoCaptureSource(capture.Video_CaptureDevices[0].Name);
  capture.Video_CaptureDevice.Format_UseBest = true;

  capture.Audio_CaptureDevice = new AudioCaptureSource(capture.Audio_CaptureDevices[0].Name);
  capture.Audio_CaptureDevice.Format_UseBest = true;

  capture.Video_Renderer.VideoRenderer = VideoRendererMode.None; // Disable video renderer

  capture.Mode = VideoCaptureMode.VideoCapture;

  capture.Output_Format = new MP4Output();

  capture.SeparateCapture_AutostartCapture = false;
  capture.SeparateCapture_Mode = SeparateCaptureMode.Normal;
  capture.SeparateCapture_Enabled = true;

  string fileName = Path.Combine(outputFolder, GetOutputFileName(DateTime.Now));

  capture.Output_Filename = fileName;

  await capture.StartAsync();

  Console.WriteLine("Started capture.");

  if (await capture.SeparateCapture_StartAsync(fileName))
  {
    Console.WriteLine("Start capture to: {0}", fileName);

    while (true)
    {
      for (int i = 0; i < 50; ++i)
      {
        Application.DoEvents();
        Thread.Sleep(100);
      }

      fileName = Path.Combine(outputFolder, GetOutputFileName(DateTime.Now));

      if (await capture.SeparateCapture_ChangeFilenameOnTheFlyAsync(fileName))
      {
        Console.WriteLine("Changed output file to: {0}", fileName);
      }
      else
      {
        Console.WriteLine("Failed changing output file.");
      }
    }
  }
}

private static string GetOutputFileName(DateTime now)
{
  return string.Format("{0}.mp4", now.ToString("yyyy-MM-dd_HHmmss"));
}

Required redists

Please contact support to get help with this tutorial. Visit our GitHub page to get more code samples.
abstract 2abstract 1abstract 3
logo
VisioForge © 2006 - 2022