public VideoFile Convert(string fileName, string format) { var videoFile = new VideoFile(fileName); var sourceCodec = CodecFactory.Extract(videoFile); CompressionCodec destinationCodec; if (format == "mp4") { destinationCodec = new MPEGCompressionCodec(); } else { destinationCodec = new OggCompressionCodec(); } var buffer = BitrateReader.Read(fileName, sourceCodec); var result = BitrateReader.Convert(buffer, destinationCodec); result = (new AudioMixer()).Fix(result); return(new VideoFile(result)); }
public FileInfo ConvertVideo(String fileName, String format) { Console.WriteLine("VideoConversionFacade: conversion started."); VideoFile file = new VideoFile(fileName); ICodec sourceCodec = CodecFactory.Extract(file); ICodec destinationCodec; if (format.Equals("mp4")) { destinationCodec = new OggCompressionCodec(); } else { destinationCodec = new MPEG4CompressionCodec(); } VideoFile buffer = BitrateReader.Read(file, sourceCodec); VideoFile intermediateResult = BitrateReader.Convert(buffer, destinationCodec); FileInfo result = (new AudioMixer()).Fix(intermediateResult); Console.WriteLine("VideoConversionFacade: conversion completed."); Console.ReadKey(); return(result); }
public AudioFile Convert(string fileName, string format) { var file = new AudioFile(fileName); var sourceCode = CodecFactory.Extract(file); Console.WriteLine(sourceCode); // you could implement switch case for different formats if (format == "mp3") { var destinationCodec = new MP3CompressionCodec(); var buffer = BitrateReader.read(fileName, sourceCode); Console.WriteLine(buffer); var result = BitrateReader.convert(buffer, destinationCodec); Console.WriteLine(result); result = (new AudioMixer()).fix(result); Console.WriteLine(result); Console.WriteLine("finishing your Audio convertor"); return(new AudioFile(result)); } Console.WriteLine("can't convert undefined format"); return(file); }