From e60fb71ff836e482915241309924e1b61f6b0802 Mon Sep 17 00:00:00 2001 From: Fedor Zhilkin Date: Thu, 17 Sep 2020 20:50:38 +0300 Subject: [PATCH] -map filtering Add map filtering to choose videostream --- .../FFMpeg/Arguments/MapStreamArgument.cs | 17 +++++++++++++++++ FFMpegCore/FFMpeg/FFMpegArguments.cs | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 FFMpegCore/FFMpeg/Arguments/MapStreamArgument.cs diff --git a/FFMpegCore/FFMpeg/Arguments/MapStreamArgument.cs b/FFMpegCore/FFMpeg/Arguments/MapStreamArgument.cs new file mode 100644 index 0000000..f6d9977 --- /dev/null +++ b/FFMpegCore/FFMpeg/Arguments/MapStreamArgument.cs @@ -0,0 +1,17 @@ +namespace FFMpegCore.Arguments +{ + /// + /// Represents choice of video stream, works with one input file + /// + public class MapStreamArgument : IArgument + { + public readonly int VideoStream; + + public MapStreamArgument(int videoStreamNum) + { + VideoStream = videoStreamNum; + } + + public string Text => $"-map 0:{VideoStream}"; + } +} \ No newline at end of file diff --git a/FFMpegCore/FFMpeg/FFMpegArguments.cs b/FFMpegCore/FFMpeg/FFMpegArguments.cs index b3285f6..db129ee 100644 --- a/FFMpegCore/FFMpeg/FFMpegArguments.cs +++ b/FFMpegCore/FFMpeg/FFMpegArguments.cs @@ -59,7 +59,8 @@ private FFMpegArguments(IInputArgument inputArgument) public FFMpegArguments WithDuration(TimeSpan? duration) => WithArgument(new DurationArgument(duration)); public FFMpegArguments WithFastStart() => WithArgument(new FaststartArgument()); public FFMpegArguments WithFrameOutputCount(int frames) => WithArgument(new FrameOutputCountArgument(frames)); - + public FFMpegArguments WithVideoStream(int videoStreamNumber) => WithArgument(new MapStreamArgument(videoStreamNumber)); + public FFMpegArguments UsingShortest(bool shortest = true) => WithArgument(new ShortestArgument(shortest)); public FFMpegArguments UsingMultithreading(bool multithread) => WithArgument(new ThreadsArgument(multithread)); public FFMpegArguments UsingThreads(int threads) => WithArgument(new ThreadsArgument(threads));