コード例 #1
0
        public async Task VideoStreamIsProcessedCorrectly()
        {
            var ffmpegProcess = new FFmpegProcessStub();

            ffmpegProcess.EnqueueOutput("    Stream #0:2: Video: h264 (High), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 47.95 tbc");

            var ffmpeg = new FFmpegTask(ffmpegProcess);

            ffmpeg.Start();

            var          outputs = new List <FFmpegOutput>();
            FFmpegOutput output;

            while ((output = await ffmpeg.GetOutputAsync()) != null)
            {
                outputs.Add(output);
            }

            var stream = outputs.OfType <MediaVideoStream>().FirstOrDefault();

            Assert.Equal(0, stream?.Media);
            Assert.Equal(2, stream?.Number);
            Assert.Equal(7, stream?.Attributes?.Count());
            Assert.Contains("h264 (High)", stream?.Attributes ?? Enumerable.Empty <string>());
            Assert.Contains("yuv420p(tv, bt709)", stream?.Attributes ?? Enumerable.Empty <string>());
            Assert.Contains("1280x720 [SAR 1:1 DAR 16:9]", stream?.Attributes ?? Enumerable.Empty <string>());
            Assert.Contains("25 fps", stream?.Attributes ?? Enumerable.Empty <string>());
            Assert.Contains("25 tbr", stream?.Attributes ?? Enumerable.Empty <string>());
            Assert.Contains("1k tbn", stream?.Attributes ?? Enumerable.Empty <string>());
            Assert.Contains("47.95 tbc", stream?.Attributes ?? Enumerable.Empty <string>());
        }
コード例 #2
0
        public async Task NullOrEmptyInputIsIgnored()
        {
            var ffmpegProcess = new FFmpegProcessStub();

            ffmpegProcess.EnqueueOutput(null);
            ffmpegProcess.EnqueueOutput(string.Empty);
            ffmpegProcess.EnqueueOutput(" ");

            var ffmpeg = new FFmpegTask(ffmpegProcess);

            ffmpeg.Start();

            var          outputs = new List <FFmpegOutput>();
            FFmpegOutput output;

            while ((output = await ffmpeg.GetOutputAsync()) != null)
            {
                outputs.Add(output);
            }

            Assert.Empty(outputs);
        }
コード例 #3
0
        public async void VersionLineIsProcessedCorrectlyAlsoInCaseOfMajorAndMinorOnly()
        {
            var ffmpegProcess = new FFmpegProcessStub();

            ffmpegProcess.EnqueueOutput("ffmpeg version 3.4 Copyright(c) 2000-2017 the FFmpeg developers");

            var ffmpeg = new FFmpegTask(ffmpegProcess);

            ffmpeg.Start();

            var          outputs = new List <FFmpegOutput>();
            FFmpegOutput output;

            while ((output = await ffmpeg.GetOutputAsync()) != null)
            {
                outputs.Add(output);
            }

            var version = outputs.OfType <FFmpegVersion>().FirstOrDefault();

            Assert.Equal("3.4", version?.Version);
        }
コード例 #4
0
        public async Task DurationAndBitRateNotAvaibleIsProcessedCorrectly()
        {
            var ffmpegProcess = new FFmpegProcessStub();

            ffmpegProcess.EnqueueOutput("  Duration: N/A, start: 0.000000, bitrate: N/A kb/s");

            var ffmpeg = new FFmpegTask(ffmpegProcess);

            ffmpeg.Start();

            var          outputs = new List <FFmpegOutput>();
            FFmpegOutput output;

            while ((output = await ffmpeg.GetOutputAsync()) != null)
            {
                outputs.Add(output);
            }

            var duration = outputs.OfType <FFmpegDuration>().FirstOrDefault();

            Assert.Equal(duration?.Duration, TimeSpan.Zero);
            Assert.Equal(0M, duration?.Start);
            Assert.Equal(0, duration?.Bitrate);
        }
コード例 #5
0
        public async Task DurationIsProcessedCorrectly()
        {
            var ffmpegProcess = new FFmpegProcessStub();

            ffmpegProcess.EnqueueOutput("  Duration: 00:41:33.50, start: 0.000000, bitrate: 4800 kb/s");

            var ffmpeg = new FFmpegTask(ffmpegProcess);

            ffmpeg.Start();

            var          outputs = new List <FFmpegOutput>();
            FFmpegOutput output;

            while ((output = await ffmpeg.GetOutputAsync()) != null)
            {
                outputs.Add(output);
            }

            var duration = outputs.OfType <FFmpegDuration>().FirstOrDefault();

            Assert.Equal(duration?.Duration, new TimeSpan(0, 0, 41, 33, 500));
            Assert.Equal(0M, duration?.Start);
            Assert.Equal(4800, duration?.Bitrate);
        }