コード例 #1
0
        /// <summary>
        /// Normalizes the FF probe result.
        /// </summary>
        /// <param name="result">The result.</param>
        public static void NormalizeFFProbeResult(InternalMediaInfoResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            if (result.format != null && result.format.tags != null)
            {
                result.format.tags = ConvertDictionaryToCaseInSensitive(result.format.tags);
            }

            if (result.streams != null)
            {
                // Convert all dictionaries to case insensitive
                foreach (var stream in result.streams)
                {
                    if (stream.tags != null)
                    {
                        stream.tags = ConvertDictionaryToCaseInSensitive(stream.tags);
                    }

                    if (stream.disposition != null)
                    {
                        stream.disposition = ConvertDictionaryToCaseInSensitive(stream.disposition);
                    }
                }
            }
        }
コード例 #2
0
        public static MediaInfo GetMediaInfo(InternalMediaInfoResult data)
        {
            var internalStreams = data.streams ?? new MediaStreamInfo[] { };

            var info = new MediaInfo
            {
                MediaStreams = internalStreams.Select(s => GetMediaStream(s, data.format))
                               .Where(i => i != null)
                               .ToList()
            };

            if (data.format != null)
            {
                info.Format = data.format.format_name;
            }

            return(info);
        }
コード例 #3
0
        public static MediaInfo GetMediaInfo(InternalMediaInfoResult data)
        {
            var internalStreams = data.streams ?? new MediaStreamInfo[] { };

            var info = new MediaInfo
            {
                MediaStreams = internalStreams.Select(s => GetMediaStream(s, data.format))
                               .Where(i => i != null)
                               .ToList()
            };

            if (data.format != null)
            {
                info.Format = data.format.format_name;

                if (!string.IsNullOrEmpty(data.format.bit_rate))
                {
                    info.TotalBitrate = int.Parse(data.format.bit_rate, UsCulture);
                }
            }

            return(info);
        }
コード例 #4
0
        public static MediaInfo GetMediaInfo(InternalMediaInfoResult data)
        {
            var internalStreams = data.streams ?? new MediaStreamInfo[] { };

            var info = new MediaInfo
            {
                MediaStreams = internalStreams.Select(s => GetMediaStream(s, data.format))
                    .Where(i => i != null)
                    .ToList()
            };

            if (data.format != null)
            {
                info.Format = data.format.format_name;

                if (!string.IsNullOrEmpty(data.format.bit_rate))
                {
                    info.TotalBitrate = int.Parse(data.format.bit_rate, UsCulture);
                }
            }

            return info;
        }
コード例 #5
0
        public static MediaInfo GetMediaInfo(InternalMediaInfoResult data)
        {
            var internalStreams = data.streams ?? new MediaStreamInfo[] { };

            var info = new MediaInfo
            {
                MediaStreams = internalStreams.Select(s => GetMediaStream(s, data.format))
                    .Where(i => i != null)
                    .ToList()
            };

            if (data.format != null)
            {
                info.Format = data.format.format_name;
            }

            return info;
        }
コード例 #6
0
ファイル: MediaEncoder.cs プロジェクト: Tensre/MediaBrowser
        /// <summary>
        /// Adds the chapters.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="standardError">The standard error.</param>
        private void AddChapters(InternalMediaInfoResult result, string standardError)
        {
            var lines = standardError.Split('\n').Select(l => l.TrimStart());

            var chapters = new List<ChapterInfo>();

            ChapterInfo lastChapter = null;

            foreach (var line in lines)
            {
                if (line.StartsWith("Chapter", StringComparison.OrdinalIgnoreCase))
                {
                    // Example:
                    // Chapter #0.2: start 400.534, end 4565.435
                    const string srch = "start ";
                    var start = line.IndexOf(srch, StringComparison.OrdinalIgnoreCase);

                    if (start == -1)
                    {
                        continue;
                    }

                    var subString = line.Substring(start + srch.Length);
                    subString = subString.Substring(0, subString.IndexOf(','));

                    double seconds;

                    if (double.TryParse(subString, NumberStyles.Any, UsCulture, out seconds))
                    {
                        lastChapter = new ChapterInfo
                            {
                                StartPositionTicks = TimeSpan.FromSeconds(seconds).Ticks
                            };

                        chapters.Add(lastChapter);
                    }
                }

                else if (line.StartsWith("title", StringComparison.OrdinalIgnoreCase))
                {
                    if (lastChapter != null && string.IsNullOrEmpty(lastChapter.Name))
                    {
                        var index = line.IndexOf(':');

                        if (index != -1)
                        {
                            lastChapter.Name = line.Substring(index + 1).Trim().TrimEnd('\r');
                        }
                    }
                }
            }

            result.Chapters = chapters;
        }