public int VideoEncodeQuality { get; set; }
a value representing the video encode quality.
this value specifies a number between 0 and 100 that indicates the tradeoff between encoding quality and encoding speed.
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;
tf.VideoBitrate = 700000;
// 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:\LEADTOOLS23\Media";
}
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