Example #1
0
        public void EnsureExceptionWhenNoOutputFileInGiven()
        {
            var portAllocator = MockRepository.GenerateMock<IPortAllocator>();
            portAllocator.Expect(x => x.NewPort()).Return(42);

            var job = new VlcVideoJob(new VideoConfiguration(), new AudioConfiguration(), portAllocator, MockRepository.GenerateMock<IStatusParser>(), MockRepository.GenerateMock<IVlcStatusSource>(), new TimeSouce(), MockRepository.GenerateMock<ILogger>())
            {
                InputFile = new FileInfo("in.txt")
            };
            job.GetVlcArguments();
        }
Example #2
0
        static void Main()
        {
            #region This region is only for use in this console example as ending the console will leave VLC running
            handler = ConsoleEventCallback;
            var osver = Environment.OSVersion;
            switch (osver.Platform)
            {
                case PlatformID.Win32NT:
                    SetConsoleCtrlHandler(handler, true);
                    break;
            }

            #endregion

            var input = new FileInfo(@"c:\Temp\inputVideo.avi");
            var output = new FileInfo(@"c:\Temp\outputVideo.mpg");

            if (!input.Exists)
            {
                throw new FileNotFoundException("Example app needs a file to convert", input.FullName);
            }

            var driver = new VlcDriver();
            //driver.VlcExePath = new FileInfo("/usr/bin/vlc"); - Only on Non Windows environments
            Job = driver.CreateVideoJob();
            Job.InputFile = input;
            Job.OutputFile = output;
            Job.VideoConfiguration.Format = VideoConfiguration.VlcVideoFormat.Mpeg2;
            Job.AudioConfiguration.Format = AudioConfiguration.ConversionFormats.Mpg;

            driver.StartJob(Job);

            while (Job.State != VlcJob.JobState.Finished)
            {
                Job.UpdateProgress();
                Console.Clear();
                Console.SetCursorPosition(0,0);
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("{0}% Complete. Remaining {1}", string.Format("{0:0.0#}", Job.PercentComplete * 100), Job.EstimatedTimeToCompletion.ToString(@"h\h\:m\m\:s\s", System.Globalization.CultureInfo.InvariantCulture));
                Thread.Sleep(1000);
            }
        }
Example #3
0
        public void EnsureVlcVideoArgumentsArePassedCorrectly()
        {
            var audioConfig = MockRepository.GenerateMock<IAudioConfiguration>();
            audioConfig.Expect(x => x.GetPartArguments()).Return("!!AFOO!!");

            var videoConfig = MockRepository.GenerateMock<IVideoConfiguration>();
            videoConfig.Expect(x => x.GetPartArguments()).Return("!!VFOO!!");

            var portAllocator = MockRepository.GenerateMock<IPortAllocator>();
            portAllocator.Expect(x => x.NewPort()).Return(42);

            var job = new VlcVideoJob(videoConfig, audioConfig, portAllocator, MockRepository.GenerateMock<IStatusParser>(), MockRepository.GenerateMock<IVlcStatusSource>(), new TimeSouce(), MockRepository.GenerateMock<ILogger>());
            var inputfile = TestUtilities.GetTestFile("SampleVideo_720x480_1mbH264.mp4");
            job.InputFile = inputfile;
            var expectedOutputFile = Path.Combine(TestUtilities.GetTestOutputDir(), "output.mp4");
            job.OutputFile = new FileInfo(expectedOutputFile);

            var expectedArguments = string.Format("-I http --http-password goose --http-port 42 \"{0}{2}SampleVideo_720x480_1mbH264.mp4\" \":sout=#transcode{{!!VFOO!!,!!AFOO!!}}:std{{dst='{1}{2}output.mp4',access=file}}\"", TestUtilities.GetTestDir(), TestUtilities.GetTestOutputDir(), Path.DirectorySeparatorChar);
            var actualArguments = job.GetVlcArguments();
            Assert.AreEqual(expectedArguments, actualArguments);
        }