Video capture to MP4 using Video Capture SDK .Net

Related products
Video Capture SDK .Net

To capture video in MP4 format using Video Capture SDK you need to configure video output format using one of classes for MP4 output. You can use several available software and hardware video encoders including Intel QuickSync, nVidia NVENC and AMD/ATI APU.

Use dialog to set settings in UI or set settings in code.

Video capture to MP4 - v8 encoder (legacy) / v10 encoder (DirectShow based)

Create VFMP4v8v10Output object for MP4 output v8/v10

VFMP4v8v10Output mp4Output = new VFMP4v8v10Output();

Set MP4 settings using settings dialog

MP4v10SettingsDialog mp4SettingsDialog = new MP4v10SettingsDialog();

mp4SettingsDialog.ShowDialog(this);
mp4SettingsDialog.SaveSettings(ref mp4Output);

Or

Set MP4 settings without using settings dialog

1. Set MP4 mode – v8 or v10

mp4Output.MP4Mode = VFMP4Mode.v8;
// or
mp4Output.MP4Mode = VFMP4Mode.v10;

2. Set video settings

mp4Output.Video.Profile = VFH264Profile.ProfileMain; // H264 profile
mp4Output.Video.Level = VFH264Level.Level4; // H264 level
mp4Output.Video.Bitrate = 2000; // bitrate

// optional parameters
mp4Output.Video.MBEncoding = VFH264MBEncoding.CABAC; //CABAC / CAVLC
mp4Output.Video.BitrateAuto = false; // true to use auto bitrate
mp4Output.Video.RateControl = VFH264RateControl.VBR; // rate control - CBR or VBR

3. Set audio settings

mp4Output.Audio_AAC.Bitrate = 192;
mp4Output.Audio_AAC.Version = VFAACVersion.MPEG4; // MPEG-4 / MPEG-2
mp4Output.Audio_AAC.Output = VFAACOutput.RAW; // RAW or ADTS
mp4Output.Audio_AAC.Object = VFAACObject.Low; // type of AAC

Apply settings

1. Use MP4 format for output

VideoCapture1.Output_Format = mp4Output;

2. Set video capture mode

VideoCapture1.Mode = VFVideoCaptureMode.VideoCapture;

3. Set file name (be sure that you have write access rights)

VideoCapture1.Output_Filename = "123.mp4";

4. Start capture

await VideoCapture1.StartAsync();

Video capture to MP4 - v10 encoder + NVENC

Create VFMP4v8v10Output object for MP4 output v10 NVENC

var mp4Output = new VFMP4v8v10Output();

Set MP4 settings using settings dialog

var mp4SettingsDialog = new MP4v10SettingsDialog();

mp4SettingsDialog.ShowDialog(this);
mp4SettingsDialog.SaveSettings(ref mp4Output);

Or

Set MP4 settings without using settings dialog

1. Set MP4 mode – v10 NVENC

mp4Output.MP4Mode = VFMP4Mode.v10_NVENC;

2. Set video settings

mp4Output.Video_NVENC.Profile = VFNVENCVideoEncoderProfile.H264_Main; // H264 profile
mp4Output.Video_NVENC.Level = VFNVENCEncoderLevel.H264_4; // H264 level
mp4Output.Video_NVENC.Bitrate = 2000; // bitrate

// optional parameters
mp4Output.Video_NVENC.RateControl = VFNVENCRateControlMode.VBR; // rate control - CBR or VBR

3. Set audio settings

mp4Output.Audio_AAC.Bitrate = 192;
mp4Output.Audio_AAC.Version = VFAACVersion.MPEG4; // MPEG-4 / MPEG-2
mp4Output.Audio_AAC.Output = VFAACOutput.RAW; // RAW or ADTS
mp4Output.Audio_AAC.Object = VFAACObject.Low; // type of AAC

Apply settings

1. Use MP4 format for output

2. Set video capture mode

VideoCapture1.Output_Format = mp4Output;
VideoCapture1.Mode = VFVideoCaptureMode.VideoCapture;

3. Set file name (be sure that you have write access rights)

VideoCapture1.Output_Filename = "123.mp4";

4. Start capture

await VideoCapture1.StartAsync();

Video capture to MP4 - v11 encoders (Media Foundation based encoders)

Using MP4 v11 output you can use hardware accelerated encoders by Intel, nVidia and AMD/ATI.

Create VFMP4v11Output object for MP4 output v11

var mp4Output = new VFMP4v11Output();

Set MP4 settings using settings dialog

var mp4SettingsDialog = new MFSettingsDialog();​

mp4SettingsDialog.ShowDialog(this);
mp4SettingsDialog.SaveSettings(ref mp4Output);
Or

Set MP4 settings without using settings dialog

1. First step – get available encoders

var filtersAvailableInfo = VideoCaptureCore.MP4_v11_GetFiltersAvailable();

2. Depending from available encoders select video codec

mp4Output.Video.Codec = VFMFVideoEncoder.MS_H264; // Microsoft H264
mp4Output.Video.Profile = VFMFH264Profile.Main; // H264 profile
mp4Output.Video.Level = VFMFH264Level.Level4; // H264 level
mp4Output.Video.AvgBitrate = 2000; // bitrate

// optional parameters
mp4Output.Video.CABAC = true; // CABAC / CAVLC
mp4Output.Video.RateControl = VFMFCommonRateControlMode.CBR; // rate control

// many other parameters available

3. Set audio settings

mp4Output.Audio.Bitrate = 192;
mp4Output.Audio.Version = VFAACVersion.MPEG4; // MPEG-4 / MPEG-2
mp4Output.Audio.Output = VFAACOutput.RAW; // RAW or ADTS
mp4Output.Audio.Object = VFAACObject.Low; // type of AAC

Apply settings

​ 1. Use MP4 format for output

VideoCapture1.Output_Format = mp4Output;

2. Set video capture mode

VideoCapture1.Mode = VFVideoCaptureMode.VideoCapture;

3. Set file name (be sure that you have write access rights)

VideoCapture1.Output_Filename = "123.mp4";

4. Start capture

await VideoCapture1.StartAsync();
Please contact support to get help with this tutorial. Visit our GitHub page to get more code samples.
VisioForge © 2006 - 2021