Reset Method

Summary
Resets the target format.
Syntax
C#
VB
C++
public void Reset() 
Public Sub Reset()  
public: 
void Reset();  
Remarks

This method will reset the target format properties to their default values. Users typically call this method to remove any values set on the video or audio attributes, also it will reset the container type. If the method fails, an error is raised. For more information, refer to the Error Codes.

Example
C#
VB
using Leadtools; 
using Leadtools.MediaFoundation; 
using LeadtoolsMediaFoundationExamples.Fixtures; 
 
public bool _result = false; 
public ConvertCtrlForm _form = new ConvertCtrlForm(); 
public ConvertCtrl _convertctrl; 
 
public void VideoFormatsExample() 
{ 
   // reference the convert control 
   _convertctrl = _form.ConvertCtrl; 
 
   // input and output files 
   string inFile = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_Source.avi"); 
   string outFile = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_VideoFormatsExample.MP4"); 
 
   try 
   { 
      // set the source for conversion 
      _convertctrl.SourceFile = inFile; 
 
      // get the MP4 target format 
      TargetFormat tf = _convertctrl.TargetFormats[TargetFormatType.MP4]; 
 
      // reset the MP4 target format 
      tf.Reset(); 
 
      // select the MP4 target format 
      tf.Selected = true; 
 
      // select H264 video format 
      int index = -1; 
      TargetVideoFormats targetvideoformats = tf.VideoFormats; 
      index = targetvideoformats.IndexOf("{34363248-0000-0010-8000-00AA00389B71}");// H264 
      targetvideoformats.Selection = index; 
 
      // select AAC audio format 
      TargetAudioFormats targetaudioformats = tf.AudioFormats; 
      index = targetaudioformats.IndexOf("{00001610-0000-0010-8000-00AA00389B71}");// AAC 
      targetaudioformats.Selection = index; 
 
      // set audio properties 
      tf.AudioAvgBytesPerSecond = 24000; 
      tf.AudioBitsPerSample = 16; 
      tf.AudioNumChannels = 2; 
      tf.AudioSamplesPerSecond = 44100; 
 
      // set video properties 
      tf.VideoEncodeQuality = 85; 
      tf.VideoFrameHeight = 240; 
      tf.VideoFrameRate = 29.26; 
      tf.VideoFrameWidth = 320; 
 
      // set the target output file and format 
      _convertctrl.TargetFile = outFile; 
 
      // set our progress event handler 
      _convertctrl.Progress += new ProgressEventHandler(ConvertCtrl_Progress); 
 
      // convert it now! 
      _convertctrl.StartConvert(); 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
 
   // we'll loop on the state and pump messages for this example. 
   // but you should not need to if running from a Windows Forms application. 
   while (_convertctrl.State == ConvertState.Running) 
      Application.DoEvents(); 
} 
 
void ConvertCtrl_Progress(object sender, ProgressEventArgs e) 
{ 
   // set the result to true if complete 
   if (e.percent == 100) 
      _result = true; 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\LEADTOOLS21\Media"; 
} 
Imports Leadtools 
Imports Leadtools.MediaFoundation 
Imports LeadtoolsMediaFoundationExamples.Fixtures 
 
Public _result As Boolean = False 
Public _form As ConvertCtrlForm = New ConvertCtrlForm() 
Public _convertctrl As ConvertCtrl 
 
Public Sub VideoFormatsExample() 
   ' reference the convert control 
   _convertctrl = _form.ConvertCtrl 
 
   ' input and output files 
   Dim inFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_Source.avi") 
   Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_VideoFormatsExample.mp4") 
 
   Try 
      ' set the source for conversion 
      _convertctrl.SourceFile = inFile 
 
      ' get MP4 target format 
      Dim tf As TargetFormat = _convertctrl.TargetFormats(TargetFormatType.MP4) 
 
      ' reset MP4 target format 
      tf.Reset() 
 
      ' select MP4 target format 
      tf.Selected = True 
 
      ' select H264 video format 
      Dim index As Integer = -1 
      Dim trgvideoformats As TargetVideoFormats = _convertctrl.TargetFormats(_convertctrl.TargetFormat).VideoFormats 
      index = trgvideoformats.IndexOf("{34363248-0000-0010-8000-00AA00389B71}") ' H264 
      trgvideoformats.Selection = index 
 
      ' select AAC audio format 
      Dim trgaudioformats As TargetAudioFormats = _convertctrl.TargetFormats(_convertctrl.TargetFormat).AudioFormats 
      index = trgaudioformats.IndexOf("{00001610-0000-0010-8000-00AA00389B71}") ' AAC 
      trgaudioformats.Selection = index 
 
      ' set audio properties 
      tf.AudioAvgBytesPerSecond = 24000 
      tf.AudioBitsPerSample = 16 
      tf.AudioNumChannels = 2 
      tf.AudioSamplesPerSecond = 44100 
 
      ' set video properties 
      tf.VideoEncodeQuality = 85 
      tf.VideoFrameHeight = 240 
      tf.VideoFrameRate = 29.26 
      tf.VideoFrameWidth = 320 
 
      ' set the target output file and format 
      _convertctrl.TargetFile = outFile 
 
      ' subscribe to the progress event 
      AddHandler _convertctrl.Progress, AddressOf ConvertCtrl_Progress 
 
      ' convert it now! 
      _convertctrl.StartConvert() 
 
   Catch e1 As Exception 
      _result = False 
   End Try 
 
   ' we'll loop on the state and pump messages for this example. 
   ' but you should not need to if running from a Windows Forms application. 
   Do While _convertctrl.State = ConvertState.Running 
      Application.DoEvents() 
   Loop 
 
End Sub 
 
Private Sub ConvertCtrl_Progress(ByVal sender As Object, ByVal e As ProgressEventArgs) 
   ' set the result to true if complete 
   If e.percent = 100 Then 
      _result = True 
   End If 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const MediaDir As String = "C:\LEADTOOLS21\Media" 
End Class 
Requirements

Target Platforms

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.MediaFoundation Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.