Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public abstract class AbstractFFmpegStreamBuilder<T extends AbstractFFmpegStream
public Long duration; // in milliseconds

public final List<String> meta_tags = new ArrayList<>();
public final List<String> maps = new ArrayList<>();

public boolean audio_enabled = true;
public String audio_codec;
Expand Down Expand Up @@ -364,6 +365,18 @@ public T addMetaTag(MetadataSpecifier spec, String key, String value) {
return getThis();
}

public T addMap(int inputIndex) {
checkArgument(inputIndex >=0, "inputIndex must be greater or equal to zero");
this.maps.add(String.valueOf(inputIndex));
return getThis();
}

public T addMap(int inputIndex, StreamSpecifier spec) {
checkArgument(inputIndex >=0, "inputIndex must be greater or equal to zero");
this.maps.add(inputIndex + ":" + spec.spec());
return getThis();
}

public T setAudioCodec(String codec) {
this.audio_enabled = true;
this.audio_codec = checkNotEmpty(codec, "codec must not be empty");
Expand Down Expand Up @@ -676,6 +689,8 @@ protected void addVideoFlags(FFmpegBuilder parent, ImmutableList.Builder<String>
}

protected void addFormatArgs(ImmutableList.Builder<String> args) {

for (String map : maps) {
args.add("-map", map);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.util.List;
import java.util.concurrent.TimeUnit;

import static net.bramp.ffmpeg.builder.StreamSpecifier.stream;
import static net.bramp.ffmpeg.builder.StreamSpecifierType.*;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -227,4 +229,13 @@ public void testAddExtraArgs() {

assertThat(removeCommon(command), is(ImmutableList.of("-some", "args")));
}

@Test
public void testAddMap() {
List<String> command = getBuilder()
.addMap(0, stream(Video))
.build(0);

assertThat(removeCommon(command), is(ImmutableList.of("-map", "0:v")));
}
}
Loading