コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }