use of org.fagu.fmv.ffmpeg.operation.InputProcessor in project fmv by f-agu.
the class Concat method beforeAddAround.
// ****************************************************
/**
* @param operation
* @param filterNaming
*/
@Override
protected void beforeAddAround(Operation<?, ?> operation, FilterNaming filterNaming) {
// copy pour acces concurrent
ArrayList<Object> arrayList = new ArrayList<>(inputs);
for (Object input : arrayList) {
Object inputObj = null;
Set<Type> types = Collections.emptySet();
if (input instanceof File) {
InputProcessor inputProcessor = builder.addMediaInputFile((File) input);
inputObj = inputProcessor;
types = getTypes(inputProcessor);
} else if (input instanceof InputProcessor) {
types = getTypes((InputProcessor) input);
inputObj = input;
} else if (input instanceof FilterComplex) {
inputObj = input;
types = ((FilterComplex) input).getTypes();
} else if (input instanceof Filter) {
throw new IllegalArgumentException("Filter forbidden: " + input.getClass().getName() + ". Wrap it with FilterComplex.create(...).");
}
if (startAtStartTime && inputObj != null) {
boolean startAt = true;
FilterInput filterInput = (FilterInput) inputObj;
for (MediaInput mediaInput : filterInput.getInputs()) {
if (mediaInput instanceof GeneratedSource) {
startAt = false;
break;
}
}
if (startAt) {
if (types.contains(Type.VIDEO) && (countVideo == null || countVideo != 0)) {
addPTS(builder, SetPTSVideo.build(), inputObj);
}
if (types.contains(Type.AUDIO) && (countAudio == null || countAudio != 0)) {
addPTS(builder, SetPTSAudio.build(), inputObj);
}
} else {
builder.filter((Filter) inputObj);
super.addInput((FilterInput) inputObj);
}
} else if (input instanceof FilterInput) {
builder.filter((Filter) inputObj);
super.addInput((FilterInput) input);
} else {
throw new IllegalArgumentException(input.getClass().getName());
}
}
}
use of org.fagu.fmv.ffmpeg.operation.InputProcessor in project fmv by f-agu.
the class FilterGraph method of.
/**
* @param operation
* @param filterNaming
* @return
*/
public static FilterGraph of(Operation<?, ?> operation) {
FilterGraph filterGraph = new FilterGraph(operation.getFilterNaming());
List<FilterComplex> filterComplexs = operation.getFilterComplexs();
for (FilterComplex filterComplex : filterComplexs) {
// System.out.println(filterComplex);
Map<IOKey, In> inputMap = filterComplex.getInputMap();
if (inputMap.isEmpty()) {
for (MediaInput mediaInput : filterComplex.getInputs()) {
if (mediaInput instanceof GeneratedSource) {
filterGraph.roots.add(filterComplex);
for (OutputKey outputKey : filterComplex.getOutputKeys()) {
filterGraph.byOutMap.add(outputKey.getLabel(), filterComplex);
}
}
}
} else {
for (Entry<IOKey, In> entry : inputMap.entrySet()) {
FilterInput filterInput = entry.getValue().getFilterInput();
for (OutputKey inputKey : filterInput.getOutputKeys()) {
filterGraph.byInMap.add(inputKey.getLabel(), filterComplex);
}
if (filterInput instanceof InputProcessor) {
filterGraph.roots.add(filterComplex);
}
for (OutputKey outputKey : filterComplex.getOutputKeys()) {
filterGraph.byOutMap.add(outputKey.getLabel(), filterComplex);
}
}
}
}
return filterGraph;
}
use of org.fagu.fmv.ffmpeg.operation.InputProcessor in project fmv by f-agu.
the class ConcatTestCase method mockInputProcessor.
// *****************************************************
/**
* @param index
* @return
*/
private InputProcessor mockInputProcessor(int index) {
InputProcessor inputProcessor = mock(InputProcessor.class);
doReturn(Collections.singletonList(Integer.toString(index))).when(inputProcessor).getOutputKeys();
MediaInput mediaInput = mock(MediaInput.class);
doReturn(Collections.singletonList(mediaInput)).when(inputProcessor).getInputs();
return inputProcessor;
}
use of org.fagu.fmv.ffmpeg.operation.InputProcessor in project fmv by f-agu.
the class FFMPEGExecutorBuilderTestCase method testInputProcessor_getInput.
/**
*/
@Test
public void testInputProcessor_getInput() {
MediaInput input = mockInput("/path/file");
InputProcessor inputProcessor = ffmpegExecutorBuilder.addMediaInput(input);
assertSame(input, inputProcessor.getInput());
}
use of org.fagu.fmv.ffmpeg.operation.InputProcessor in project fmv by f-agu.
the class FFMPEGExecutorBuilderTestCase method testInputProcessor_duration.
// ======================== INPUT PROCESSOR ========================
/**
*/
@Test
public void testInputProcessor_duration() {
MediaInput input = mockInput("/path/file");
InputProcessor inputProcessor = ffmpegExecutorBuilder.addMediaInput(input);
inputProcessor.duration(new Duration(1, 2, 3.4));
assertArgs("-t", "01:02:03.400", "-i", "/path/file");
}
Aggregations