diff --git a/FFMpegCore/FFMpeg/FFMpeg.cs b/FFMpegCore/FFMpeg/FFMpeg.cs
index 58526b8..3939502 100644
--- a/FFMpegCore/FFMpeg/FFMpeg.cs
+++ b/FFMpegCore/FFMpeg/FFMpeg.cs
@@ -239,6 +239,46 @@ public static bool Join(string output, params string[] videos)
}
}
+ private static FFMpegArgumentProcessor BaseSubVideo(string input, string output, TimeSpan startTime, TimeSpan endTime)
+ {
+ if (Path.GetExtension(input) != Path.GetExtension(output))
+ {
+ output = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output), Path.GetExtension(input));
+ }
+
+ return FFMpegArguments
+ .FromFileInput(input, true, options => options.Seek(startTime).EndSeek(endTime))
+ .OutputToFile(output, true, options => options.CopyChannel());
+ }
+
+ ///
+ /// Creates a new video starting and ending at the specified times
+ ///
+ /// Input video file.
+ /// Output video file.
+ /// The start time of when the sub video needs to start
+ /// The end time of where the sub video needs to end
+ /// Output video information.
+ public static bool SubVideo(string input, string output, TimeSpan startTime, TimeSpan endTime)
+ {
+ return BaseSubVideo(input, output, startTime, endTime)
+ .ProcessSynchronously();
+ }
+
+ ///
+ /// Creates a new video starting and ending at the specified times
+ ///
+ /// Input video file.
+ /// Output video file.
+ /// The start time of when the sub video needs to start
+ /// The end time of where the sub video needs to end
+ /// Output video information.
+ public static async Task SubVideoAsync(string input, string output, TimeSpan startTime, TimeSpan endTime)
+ {
+ return await BaseSubVideo(input, output, startTime, endTime)
+ .ProcessAsynchronously();
+ }
+
///
/// Records M3U8 streams to the specified output.
///