Related products: Video Capture SDK .Net

Video capture to custom output format using Video Capture SDK .Net

Currently, there are several options for connecting third-party DirectShow filters for you to be able to get the necessary format.

VFCustomOutput class used to set custom output settings.

VFCustomOutput customOutput = new VFCustomOutput();

First option

An audio codec, a video codec and a multiplexer - different filters. You can use both DS filters and regular codecs as codecs.

 

1. Get lists of audio and video codecs and fill comboboxes

foreach (string codec in VideoCapture1.Video_Codecs)
{
    cbCustomVideoCodecs.Items.Add(codec);
}

foreach (string codec in VideoCapture1.Audio_Codecs)
{
    cbCustomAudioCodecs.Items.Add(codec);
}

2. Get list of DirectShow filters

foreach (string directShowFilter in VideoCapture1.DirectShow_Filters)
{
    cbCustomDSFilterA.Items.Add(directShowFilter);
    cbCustomDSFilterV.Items.Add(directShowFilter);
    cbCustomMuxer.Items.Add(directShowFilter);
    cbCustomFilewriter.Items.Add(directShowFilter); 
}

3. Select filters and codecs

if (rbCustomUseVideoCodecsCat.Checked)
{
    customOutput.Video_Codec = cbCustomVideoCodecs.Text;
    customOutput.Video_Codec_UseFiltersCategory = false;
}
else
{
    customOutput.Video_Codec = cbCustomDSFilterV.Text;
    customOutput.Video_Codec_UseFiltersCategory = true;
}

if (rbCustomUseAudioCodecsCat.Checked)
{
    customOutput.Audio_Codec = cbCustomAudioCodecs.Text;
    customOutput.Audio_Codec_UseFiltersCategory = false;
}
else
{
    customOutput.Audio_Codec = cbCustomDSFilterA.Text;
    customOutput.Audio_Codec_UseFiltersCategory = true;
}

customOutput.MuxFilter_Name = cbCustomMuxer.Text;
customOutput.MuxFilter_IsEncoder = false;

4. If you need a special File Writer filter, you should specify it. It is true for both options described above.

customOutput.SpecialFileWriter_Needed = cbUseSpecialFilewriter.Checked;
customOutput.SpecialFileWriter_FilterName = cbCustomFilewriter.Text;

Second option

A multiplexer, a video codec and an audio codec – one and the same filter. Another difference is whether the filter can write to a file itself, or you should use the standard File Writer filter, or you need another special filter. In the first two cases, VisioForge Video Capture will detect it automatically and set the necessary parameters, but you have to specify the necessary filter yourself in the third case. And now let us see what the code for different options looks like.

 

1. Get list of DirectShow filters

foreach (string directShowFilter in VideoCapture1.DirectShow_Filters)
{
    cbCustomDSFilterA.Items.Add(directShowFilter);
    cbCustomDSFilterV.Items.Add(directShowFilter);
    cbCustomMuxer.Items.Add(directShowFilter);
    cbCustomFilewriter.Items.Add(directShowFilter); 
}

2. Select multiplexer (mux) filter

customOutput.MuxFilter_Name = cbCustomMuxer.Text;
customOutput.MuxFilter_IsEncoder = true;

3. If you need a special File Writer filter, you should specify it. It is true for both options described above.

customOutput.SpecialFileWriter_Needed = cbUseSpecialFilewriter.Checked;
customOutput.SpecialFileWriter_FilterName = cbCustomFilewriter.Text;

Third option

Settings dialog usage

CustomFormatSettingsDialog customFormatSettingsDialog = new CustomFormatSettingsDialog(VideoCapture1.Video_Codecs.ToArray(), VideoCapture1.Audio_Codecs.ToArray(), VideoCapture1.DirectShow_Filters.ToArray());
customFormatSettingsDialog.SaveSettings(ref customOutput);

Apply settings

1. Set output settings

VideoCapture1.Output_Format = customOutput;

2. Set video capture mode and file name (be sure that you have write access rights)

VideoCapture1.Mode = VFVideoCaptureMode.VideoCapture;
VideoCapture1.Output_Filename = "c:\\123.mp4";

3. Start capture

VideoCapture1.Start();

VisioForge © 2006-2019

  • GitHub-Mark-64px
  • Twitter Социальные Иконка
  • VisioForge Facebook page
  • YouTube channel