public void Reset() Public Sub Reset() public:void Reset();
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.
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 filesstring 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 formatTargetFormat tf = _convertctrl.TargetFormats[TargetFormatType.MP4];// reset the MP4 target formattf.Reset();// select the MP4 target formattf.Selected = true;// select H264 video formatint index = -1;TargetVideoFormats targetvideoformats = tf.VideoFormats;index = targetvideoformats.IndexOf("{34363248-0000-0010-8000-00AA00389B71}");// H264targetvideoformats.Selection = index;// select AAC audio formatTargetAudioFormats targetaudioformats = tf.AudioFormats;index = targetaudioformats.IndexOf("{00001610-0000-0010-8000-00AA00389B71}");// AACtargetaudioformats.Selection = index;// set audio propertiestf.AudioAvgBytesPerSecond = 24000;tf.AudioBitsPerSample = 16;tf.AudioNumChannels = 2;tf.AudioSamplesPerSecond = 44100;// set video propertiestf.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 completeif (e.percent == 100)_result = true;}static class LEAD_VARS{public const string MediaDir = @"C:\LEADTOOLS21\Media";}
Imports LeadtoolsImports Leadtools.MediaFoundationImports LeadtoolsMediaFoundationExamples.FixturesPublic _result As Boolean = FalsePublic _form As ConvertCtrlForm = New ConvertCtrlForm()Public _convertctrl As ConvertCtrlPublic Sub VideoFormatsExample()' reference the convert control_convertctrl = _form.ConvertCtrl' input and output filesDim 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 formatDim tf As TargetFormat = _convertctrl.TargetFormats(TargetFormatType.MP4)' reset MP4 target formattf.Reset()' select MP4 target formattf.Selected = True' select H264 video formatDim index As Integer = -1Dim trgvideoformats As TargetVideoFormats = _convertctrl.TargetFormats(_convertctrl.TargetFormat).VideoFormatsindex = trgvideoformats.IndexOf("{34363248-0000-0010-8000-00AA00389B71}") ' H264trgvideoformats.Selection = index' select AAC audio formatDim trgaudioformats As TargetAudioFormats = _convertctrl.TargetFormats(_convertctrl.TargetFormat).AudioFormatsindex = trgaudioformats.IndexOf("{00001610-0000-0010-8000-00AA00389B71}") ' AACtrgaudioformats.Selection = index' set audio propertiestf.AudioAvgBytesPerSecond = 24000tf.AudioBitsPerSample = 16tf.AudioNumChannels = 2tf.AudioSamplesPerSecond = 44100' set video propertiestf.VideoEncodeQuality = 85tf.VideoFrameHeight = 240tf.VideoFrameRate = 29.26tf.VideoFrameWidth = 320' set the target output file and format_convertctrl.TargetFile = outFile' subscribe to the progress eventAddHandler _convertctrl.Progress, AddressOf ConvertCtrl_Progress' convert it now!_convertctrl.StartConvert()Catch e1 As Exception_result = FalseEnd 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.RunningApplication.DoEvents()LoopEnd SubPrivate Sub ConvertCtrl_Progress(ByVal sender As Object, ByVal e As ProgressEventArgs)' set the result to true if completeIf e.percent = 100 Then_result = TrueEnd IfEnd SubPublic NotInheritable Class LEAD_VARSPublic Const MediaDir As String = "C:\LEADTOOLS21\Media"End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
