mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 00:24:14 +01:00
Implemented AddChapters for convenience
This commit is contained in:
parent
2605ac1a54
commit
e2dc91660c
1 changed files with 12 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace FFMpegCore.Builders.MetaData
|
||||
|
@ -19,6 +20,17 @@ public MetaDataBuilder AddChapter(ChapterData chapterData)
|
|||
return this;
|
||||
}
|
||||
|
||||
public MetaDataBuilder AddChapters<T>(IEnumerable<T> values, Func<T, (TimeSpan duration, string title)> chapterGetter)
|
||||
{
|
||||
foreach (T value in values)
|
||||
{
|
||||
var (duration, title) = chapterGetter(value);
|
||||
AddChapter(duration, title);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public MetaDataBuilder AddChapter(TimeSpan duration, string? title = null)
|
||||
{
|
||||
var start = _metaData.Chapters.LastOrDefault()?.End ?? TimeSpan.Zero;
|
||||
|
|
Loading…
Reference in a new issue