Screen capture to MP4 file in C# (video tutorial with code) in Video Capture SDK .Net
YouTube tutorial and C# sample code
Screen capture to MP4 without audio
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using VisioForge.Types.OutputFormat;
namespace SampleCapture
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btStart_Click(object sender, EventArgs e)
{
// set screen capture with full screen enabled
videoCapture1.Screen_Capture_Source = new VisioForge.Types.Sources.ScreenCaptureSourceSettings() { FullScreen = true };
// disable audio playback and recording
videoCapture1.Audio_PlayAudio = videoCapture1.Audio_RecordAudio = false;
// set output filename, output format and screen capture mode
videoCapture1.Output_Filename = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) + "\\output.mp4";
videoCapture1.Output_Format = new VFMP4v8v10Output();
videoCapture1.Mode = VisioForge.Types.VFVideoCaptureMode.ScreenCapture;
videoCapture1.Start();
}
private void btStop_Click(object sender, EventArgs e)
{
videoCapture1.Stop();
}
}
}
Screen capture to MP4 with audio
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using VisioForge.Types.OutputFormat;
namespace SampleCapture
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btStart_Click(object sender, EventArgs e)
{
// set screen capture with full screen enabled
videoCapture1.Screen_Capture_Source = new VisioForge.Types.Sources.ScreenCaptureSourceSettings() { FullScreen = true };
// select first audio device with default parameters
videoCapture1.Audio_CaptureDevice = videoCapture1.Audio_CaptureDevicesInfo[0].Name;
// disable audio playback
videoCapture1.Audio_PlayAudio = false;
// enable audio recording
videoCapture1.Audio_RecordAudio = true;
// set output filename, output format and screen capture mode
videoCapture1.Output_Filename = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) + "\output.mp4";
videoCapture1.Output_Format = new VFMP4v8v10Output();
videoCapture1.Mode = VisioForge.Types.VFVideoCaptureMode.ScreenCapture;
videoCapture1.Start();
}
private void btStop_Click(object sender, EventArgs e)
{
videoCapture1.Stop();
}
}
}