Media Processor Add-on can be used only to read different kinds of media files; it cannot write them or convert to other formats. But if you have AVI Processor Add-on installed, you may use a combination of Media Processor Add-on (for reading files) and AVI Processor Add-on (for writing files) to convert your video to the AVI format.
The function that will convert video to the AVI format should perform the following operations:
Public Sub ConvertToAvi(ByVal inputFilename As String, ByVal outputFilename As _ String) Try 'Create the reader Dim reader As IFormatReader = MediaFormatManager.CreateFormatReader _ (inputFilename) 'Create the writer and initialize its parameters Dim writer As AviWriter = New AviWriter writer.Width = reader.LoadFrame(0).Width writer.Height = reader.LoadFrame(0).Height writer.CompressorHandler = AviCompressor.DefaultCompressorHandler 'Open the output file. Note that this should be done after writer 'initialization writer.Open(outputFilename) 'Copy frames from the reader to the writer Dim frame As IFrame For Each frame In reader writer.AddFrame(frame) Next writer.Close() reader.Close() Catch ex As Exception Console.WriteLine(ex) End Try End Sub
public static void ConvertToAvi(string inputFilename, string outputFilename) { try { //Create the reader IFormatReader reader = MediaFormatManager.CreateFormatReader(inputFilename); //Create the writer and initialize its parameters AviWriter writer = new AviWriter(); writer.Width = reader.LoadFrame(0).Width; writer.Height = reader.LoadFrame(0).Height; writer.CompressorHandler = AviCompressor.DefaultCompressorHandler; //Open the output file. Note that this should be done after writer //initialization writer.Open(outputFilename); //Copy frames from the reader to the writer foreach (IFrame frame in reader) writer.AddFrame(frame); writer.Close(); reader.Close(); } catch (System.Exception ex) { Console.WriteLine(ex); } }