mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 00:24:14 +01:00
Add negative mapping to select stream (deselect)
Former-commit-id: 40f97594f0
This commit is contained in:
parent
a776db85d2
commit
f1e13326b8
2 changed files with 12 additions and 4 deletions
|
@ -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}";
|
||||
}
|
||||
}
|
|
@ -63,8 +63,14 @@ public FFMpegArgumentOptions WithAudioFilters(Action<AudioFilterOptions> 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<int> streamIndices, int inputFileIndex = 0, Channel channel = Channel.All) =>
|
||||
streamIndices.Aggregate(this, (options, streamIndex) => options.SelectStream(streamIndex, inputFileIndex, channel));
|
||||
public FFMpegArgumentOptions SelectStreams(IEnumerable<int> 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<int> 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));
|
||||
|
|
Loading…
Reference in a new issue