diff --git a/FFMpegCore/FFMpeg/Arguments/MapStreamArgument.cs b/FFMpegCore/FFMpeg/Arguments/MapStreamArgument.cs index 66087b6..a9813c7 100644 --- a/FFMpegCore/FFMpeg/Arguments/MapStreamArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/MapStreamArgument.cs @@ -10,8 +10,9 @@ public class MapStreamArgument : IArgument private readonly int _inputFileIndex; private readonly int _streamIndex; private readonly Channel _channel; + private readonly bool _negativeMap; - public MapStreamArgument(int streamIndex, int inputFileIndex, Channel channel = Channel.All) + public MapStreamArgument(int streamIndex, int inputFileIndex, Channel channel = Channel.All, bool negativeMap = false) { if (channel == Channel.Both) { @@ -21,8 +22,9 @@ public MapStreamArgument(int streamIndex, int inputFileIndex, Channel channel = _inputFileIndex = inputFileIndex; _streamIndex = streamIndex; _channel = channel; + _negativeMap = negativeMap; } - public string Text => $"-map {_inputFileIndex}{_channel.StreamType()}:{_streamIndex}"; + public string Text => $"-map {(_negativeMap?"-":"")}{_inputFileIndex}{_channel.StreamType()}:{_streamIndex}"; } } \ No newline at end of file diff --git a/FFMpegCore/FFMpeg/FFMpegArgumentOptions.cs b/FFMpegCore/FFMpeg/FFMpegArgumentOptions.cs index a84c86e..1ff892a 100644 --- a/FFMpegCore/FFMpeg/FFMpegArgumentOptions.cs +++ b/FFMpegCore/FFMpeg/FFMpegArgumentOptions.cs @@ -63,8 +63,14 @@ public FFMpegArgumentOptions WithAudioFilters(Action audioFi public FFMpegArgumentOptions OverwriteExisting() => WithArgument(new OverwriteArgument()); public FFMpegArgumentOptions SelectStream(int streamIndex, int inputFileIndex = 0, Channel channel = Channel.All) => WithArgument(new MapStreamArgument(streamIndex, inputFileIndex, channel)); - public FFMpegArgumentOptions SelectStreams(IEnumerable streamIndices, int inputFileIndex = 0, Channel channel = Channel.All) => - streamIndices.Aggregate(this, (options, streamIndex) => options.SelectStream(streamIndex, inputFileIndex, channel)); + public FFMpegArgumentOptions SelectStreams(IEnumerable streamIndices, int inputFileIndex = 0, + Channel channel = Channel.All) => streamIndices.Aggregate(this, + (options, streamIndex) => options.SelectStream(streamIndex, inputFileIndex, channel)); + public FFMpegArgumentOptions DeselectStream(int streamIndex, int inputFileIndex = 0, + Channel channel = Channel.All) => WithArgument(new MapStreamArgument(streamIndex, inputFileIndex, channel, true)); + public FFMpegArgumentOptions DeselectStreams(IEnumerable streamIndices, int inputFileIndex = 0, + Channel channel = Channel.All) => streamIndices.Aggregate(this, + (options, streamIndex) => options.DeselectStream(streamIndex, inputFileIndex, channel)); public FFMpegArgumentOptions ForceFormat(ContainerFormat format) => WithArgument(new ForceFormatArgument(format)); public FFMpegArgumentOptions ForceFormat(string format) => WithArgument(new ForceFormatArgument(format));