mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-14 02:04:14 +01:00
Create end seek argument
This commit is contained in:
parent
e32dd3a7f7
commit
fe5c1f5b58
3 changed files with 43 additions and 0 deletions
|
@ -258,6 +258,13 @@ public void Builder_BuildString_Seek()
|
||||||
Assert.AreEqual("-ss 00:00:10.000 -i \"input.mp4\" -ss 00:00:10.000 \"output.mp4\"", str);
|
Assert.AreEqual("-ss 00:00:10.000 -i \"input.mp4\" -ss 00:00:10.000 \"output.mp4\"", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_EndSeek()
|
||||||
|
{
|
||||||
|
var str = FFMpegArguments.FromFileInput("input.mp4", false, opt => opt.EndSeek(TimeSpan.FromSeconds(10))).OutputToFile("output.mp4", false, opt => opt.EndSeek(TimeSpan.FromSeconds(10))).Arguments;
|
||||||
|
Assert.AreEqual("-to 00:00:10.000 -i \"input.mp4\" -to 00:00:10.000 \"output.mp4\"", str);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_Shortest()
|
public void Builder_BuildString_Shortest()
|
||||||
{
|
{
|
||||||
|
|
35
FFMpegCore/FFMpeg/Arguments/EndSeekArgument.cs
Normal file
35
FFMpegCore/FFMpeg/Arguments/EndSeekArgument.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FFMpegCore.Arguments
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents seek parameter
|
||||||
|
/// </summary>
|
||||||
|
public class EndSeekArgument : IArgument
|
||||||
|
{
|
||||||
|
public readonly TimeSpan? SeekTo;
|
||||||
|
|
||||||
|
public EndSeekArgument(TimeSpan? seekTo)
|
||||||
|
{
|
||||||
|
SeekTo = seekTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Text {
|
||||||
|
get {
|
||||||
|
if(SeekTo.HasValue)
|
||||||
|
{
|
||||||
|
int hours = SeekTo.Value.Hours;
|
||||||
|
if(SeekTo.Value.Days > 0)
|
||||||
|
{
|
||||||
|
hours += SeekTo.Value.Days * 24;
|
||||||
|
}
|
||||||
|
return $"-to {hours.ToString("00")}:{SeekTo.Value.Minutes.ToString("00")}:{SeekTo.Value.Seconds.ToString("00")}.{SeekTo.Value.Milliseconds.ToString("000")}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,6 +54,7 @@ public FFMpegArgumentOptions WithAudioFilters(Action<AudioFilterOptions> audioFi
|
||||||
public FFMpegArgumentOptions WithCustomArgument(string argument) => WithArgument(new CustomArgument(argument));
|
public FFMpegArgumentOptions WithCustomArgument(string argument) => WithArgument(new CustomArgument(argument));
|
||||||
|
|
||||||
public FFMpegArgumentOptions Seek(TimeSpan? seekTo) => WithArgument(new SeekArgument(seekTo));
|
public FFMpegArgumentOptions Seek(TimeSpan? seekTo) => WithArgument(new SeekArgument(seekTo));
|
||||||
|
public FFMpegArgumentOptions EndSeek(TimeSpan? seekTo) => WithArgument(new EndSeekArgument(seekTo));
|
||||||
public FFMpegArgumentOptions Loop(int times) => WithArgument(new LoopArgument(times));
|
public FFMpegArgumentOptions Loop(int times) => WithArgument(new LoopArgument(times));
|
||||||
public FFMpegArgumentOptions OverwriteExisting() => WithArgument(new OverwriteArgument());
|
public FFMpegArgumentOptions OverwriteExisting() => WithArgument(new OverwriteArgument());
|
||||||
public FFMpegArgumentOptions SelectStream(int streamIndex, int inputFileIndex = 0,
|
public FFMpegArgumentOptions SelectStream(int streamIndex, int inputFileIndex = 0,
|
||||||
|
|
Loading…
Reference in a new issue