Example #1
0
        private List <ChapterAtom> ReOrderChaptersAndTimeCodes(IList <MergePart> segmentParts, MkvInfo baseInfo, List <ChapterAtom> chapters)
        {
            var prev = new TimeSpan();

            foreach (var chapter in chapters)
            {
                // Base info unless we say otherwise...
                MkvInfo info = null;

                if (chapter.ReferencedSegmentUid != null)
                {
                    var segment = segmentParts.First(x => x.Info.SegmentUid.IsSame(chapter.ReferencedSegmentUid));
                    info = segment.Info;

                    chapter.ChapterTimecodeStart = TimeCodeUtil.TimespanToTimeCode(prev);
                    prev = prev.Add(info.Duration);
                    chapter.ChapterTimecodeEnd = TimeCodeUtil.TimespanToTimeCode(prev);
                }
                else
                {
                    Console.WriteLine("Skipping a chapter from main file; it is presumed to be correct... but it may not be~!");

                    // Hand over; hopefully it's correct...
                    prev = TimeCodeUtil.TimeCodeToTimespan(chapter.ChapterTimecodeEnd);
                }
            }

            return(chapters);
        }
Example #2
0
        private int TimecodeComparator(ChapterAtom x, ChapterAtom y)
        {
            var firstStart = TimeCodeUtil.TimeCodeToTimespan(x.ChapterTimecodeStart);
            var secondStart = TimeCodeUtil.TimeCodeToTimespan(y.ChapterTimecodeStart);

            return firstStart.CompareTo(secondStart);

        }
Example #3
0
        private bool AreChapterStartTimesLinearlyIncreasing(IList <ChapterAtom> chapters)
        {
            var prev = TimeCodeUtil.TimeCodeToTimespan(chapters.First().ChapterTimecodeStart);

            foreach (var chapter in chapters)
            {
                var timeSpan = TimeCodeUtil.TimeCodeToTimespan(chapter.ChapterTimecodeStart);
                if (timeSpan < prev)
                {
                    return(false);
                }
                prev = timeSpan;
            }
            return(true);
        }