Esempio n. 1
0
        public string GetInfo(ExtractorInfoType type)
        {
            var process = FFprobe.GetProcess();

            switch (type)
            {
            case ExtractorInfoType.AudioCodec:
                process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.AudioCodec);
                break;

            case ExtractorInfoType.VideoCodec:
                process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoCodec);
                break;

            case ExtractorInfoType.Bitrate:
                process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoBitrate);
                break;

            case ExtractorInfoType.Dimension:
                process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoDimension);
                break;

            case ExtractorInfoType.Duration:
                process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoDuration);
                break;

            case ExtractorInfoType.Framerate:
                process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoFramerate);
                break;
            }
            var data = GetProcessOutput(process);

            return(data);
        }
Esempio n. 2
0
        public void Cleanup()
        {
            _probe = null;

            _vp?.Dispose();
            _vp = null;
        }
Esempio n. 3
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;

            var def = new Size(500, 300);

            probe = probe ?? new FFprobe(path);

            if (!probe.HasVideo())
            {
                context.CanResize                = false;
                context.TitlebarAutoHide         = false;
                context.TitlebarBlurVisibility   = false;
                context.TitlebarColourVisibility = false;
            }
            else
            {
                context.TitlebarAutoHide         = true;
                context.UseDarkTheme             = true;
                context.CanResize                = true;
                context.TitlebarAutoHide         = true;
                context.TitlebarBlurVisibility   = true;
                context.TitlebarColourVisibility = true;
            }

            var windowSize = probe.GetViewSize() == Size.Empty ? def : probe.GetViewSize();

            windowSize.Width  = Math.Max(def.Width, windowSize.Width);
            windowSize.Height = Math.Max(def.Height, windowSize.Height);

            context.SetPreferredSizeFit(windowSize, 0.6);
            context.TitlebarOverlap = true;
        }
Esempio n. 4
0
        public string GetAudioCodec()
        {
            var process = FFprobe.GetProcess();

            process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.AudioCodec);
            var codec = GetProcessOutput(process);

            return(codec);
        }
Esempio n. 5
0
        public string GetVideoDimension()
        {
            var ffprobeProcess = FFprobe.GetProcess();

            ffprobeProcess.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoDimension);
            var dimension = GetProcessOutput(ffprobeProcess);

            return(dimension);
        }
Esempio n. 6
0
        public TimeSpan GetVideoDuration()
        {
            var process = FFprobe.GetProcess();

            process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoDuration);
            var output   = GetProcessOutput(process);
            var duration = ConvertToTimeSpan(output);

            return(duration);
        }
Esempio n. 7
0
        public double GetVideoFramerate()
        {
            var process = FFprobe.GetProcess();

            process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoFramerate);
            var output    = GetProcessOutput(process);
            var framerate = ConvertToDouble(output);

            return(framerate);
        }
Esempio n. 8
0
        public MetadataInfo GetVideoMetaDataInfo()
        {
            var process = FFprobe.GetProcess();

            process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoMetaData);
            var output     = GetProcessOutput(process);
            var audioCodec = GetAudioCodec();
            var metaData   = GetMetaDataFromOutput(output, audioCodec);

            return(metaData);
        }
Esempio n. 9
0
        public async Task <string> GetAudioCodecAsync()
        {
            var ffprobeProcess = FFprobe.GetProcess();

            ffprobeProcess.StartInfo.Arguments = GetStartArgument(FFprobeParameter.AudioCodec);
            var codec = await Task.Run(async() =>
            {
                var output = await GetProcessOutputAsync(ffprobeProcess);
                return(output);
            });

            return(codec);
        }
Esempio n. 10
0
        public async Task <string> GetVideoDimensionAsync()
        {
            var ffprobeProcess = FFprobe.GetProcess();

            ffprobeProcess.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoDimension);
            var dimension = await Task.Run(async() =>
            {
                var output = await GetProcessOutputAsync(ffprobeProcess);
                return(output);
            });

            return(dimension);
        }
Esempio n. 11
0
        public async Task <TimeSpan> GetVideoDurationAsync()
        {
            var ffprobeProcess = FFprobe.GetProcess();

            ffprobeProcess.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoDuration);
            var duration = await Task.Run(async() =>
            {
                var output = await GetProcessOutputAsync(ffprobeProcess);
                var data   = ConvertToTimeSpan(output);
                return(data);
            });

            return(duration);
        }
Esempio n. 12
0
        public async Task <double> GetVideoFramerateAsync()
        {
            var ffprobeProcess = FFprobe.GetProcess();

            ffprobeProcess.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoFramerate);
            var framerate = await Task.Run(async() =>
            {
                var output = await GetProcessOutputAsync(ffprobeProcess);
                var data   = ConvertToDouble(output);
                return(data);
            });

            return(framerate);
        }
Esempio n. 13
0
        public void Prepare(string path, ContextObject context)
        {
            var def = new Size(450, 450);

            _probe = new FFprobe(path);
            var mediaSize = _probe.GetViewSize();

            var windowSize = mediaSize == Size.Empty ? def : mediaSize;

            windowSize.Width  = Math.Max(def.Width, windowSize.Width);
            windowSize.Height = Math.Max(def.Height, windowSize.Height);

            context.SetPreferredSizeFit(windowSize, 0.6);
        }
Esempio n. 14
0
        public async Task <MetadataInfo> GetVideoMetaDataInfoAsync()
        {
            var process = FFprobe.GetProcess();

            process.StartInfo.Arguments = GetStartArgument(FFprobeParameter.VideoMetaData);
            var dataTask = Task.Run(async() =>
            {
                var output = await GetProcessOutputAsync(process);
                return(output);
            });
            var audioCodecTask = GetAudioCodecAsync();
            var data           = await Task.WhenAll(dataTask, audioCodecTask);

            var metaData = GetMetaDataFromOutput(data[0], data[1]);

            return(metaData);
        }
Esempio n. 15
0
        public bool CanHandle(string path)
        {
            if (Directory.Exists(path))
            {
                return(false);
            }

            var blacklist = new[]
            {
                // tty
                ".ans", ".art", ".asc", ".diz", ".ice", ".nfo", ".txt", ".vt",
                // ico
                ".ico", ".icon",
                // bmp_pipe
                ".bmp",
                // ass
                ".ass",
                // apng
                ".png", ".apng",
                // asterisk (pcmdec)
                ".gsm", ".sln"
            };

            if (blacklist.Contains(Path.GetExtension(path).ToLower()))
            {
                return(false);
            }

            var probe = new FFprobe(path);

            // check if it is an image. Normal images shows "image2"
            // "dpx,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png,"
            // "ppm,sgi,tga,tif,tiff,jp2,j2c,xwd,sun,ras,rs,im1,im8,im24,"
            // "sunras,xbm,xface"
            if (probe.GetFormatName().ToLower() == "image2")
            {
                return(false);
            }

            return(probe.CanDecode());
        }
Esempio n. 16
0
        private MediaVersion ProjectToMediaVersion(FFprobe probeOutput) =>
        Optional(probeOutput)
        .Filter(json => json?.format != null && json.streams != null)
        .ToValidation <BaseError>("Unable to parse ffprobe output")
        .ToEither <FFprobe>()
        .Match(
            json =>
        {
            var duration = TimeSpan.FromSeconds(double.Parse(json.format.duration));

            var version = new MediaVersion {
                Name = "Main", Duration = duration
            };

            FFprobeStream audioStream = json.streams.FirstOrDefault(s => s.codec_type == "audio");
            if (audioStream != null)
            {
                version.AudioCodec = audioStream.codec_name;
            }

            FFprobeStream videoStream = json.streams.FirstOrDefault(s => s.codec_type == "video");
            if (videoStream != null)
            {
                version.SampleAspectRatio  = videoStream.sample_aspect_ratio;
                version.DisplayAspectRatio = videoStream.display_aspect_ratio;
                version.Width         = videoStream.width;
                version.Height        = videoStream.height;
                version.VideoCodec    = videoStream.codec_name;
                version.VideoProfile  = (videoStream.profile ?? string.Empty).ToLowerInvariant();
                version.VideoScanKind = ScanKindFromFieldOrder(videoStream.field_order);
            }

            return(version);
        },
            _ => new MediaVersion {
            Name = "Main"
        });
Esempio n. 17
0
 public FFprobeExtractor(FFprobe fFprobe, string filename)
 {
     FFprobe  = fFprobe;
     Filename = filename;
 }
 internal MediaVersion ProjectToMediaVersion(string path, FFprobe probeOutput) =>
 Optional(probeOutput)
 .Filter(json => json?.format != null && json.streams != null)
 .ToValidation <BaseError>("Unable to parse ffprobe output")
 .ToEither <FFprobe>()
 .Match(