use of org.fagu.fmv.ffmpeg.operation.Type in project fmv by f-agu.
the class GenericFilterExec method makeFilter.
/**
* @see org.fagu.fmv.core.exec.FilterExec#makeFilter(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder, Cache)
*/
@Override
public Filter makeFilter(FFMPEGExecutorBuilder builder, Cache cache) {
Filter filter = getFilter();
// parameters
ObjectInvoker.invoke(filter, attributeMap);
FilterComplexBase filterComplex = filter instanceof FilterComplexBase ? (FilterComplexBase) filter : FilterComplex.create(filter);
builder.filter(filterComplex);
Set<Type> undeclaredTypes = populateWithIdentifiables(filterComplex, cache, builder);
if (!undeclaredTypes.isEmpty()) {
undeclaredTypes(undeclaredTypes, filterComplex, cache, builder);
}
return filterComplex;
}
use of org.fagu.fmv.ffmpeg.operation.Type in project fmv by f-agu.
the class GenericFilterExec method populateWithIdentifiables.
// *************************************************************
/**
* @param filterComplex
* @param cache
* @param builder
* @return
*/
protected Set<Type> populateWithIdentifiables(FilterComplexBase filterComplex, Cache cache, FFMPEGExecutorBuilder builder) {
Set<Type> undeclaredTypes = new HashSet<>(filterComplex.getTypes());
for (Identifiable identifiable : getIdentifiableChildren()) {
if (identifiable.isExecutable()) {
File file = getProject().getFileCache().getFile((Executable) identifiable, cache);
InputProcessor inputProcessor = builder.addMediaInputFile(file);
addInputIntoFilter(filterComplex, inputProcessor, undeclaredTypes);
} else if (identifiable.isSource()) {
FilterInput filterInput = ((Source) identifiable).createAndAdd(builder);
addInputIntoFilter(filterComplex, filterInput, undeclaredTypes);
} else if (identifiable.isFilterExec()) {
Filter inFilter = ((FilterExec) identifiable).makeFilter(builder, cache);
addInputIntoFilter(filterComplex, (FilterComplexBase) inFilter, undeclaredTypes);
}
}
return undeclaredTypes;
}
use of org.fagu.fmv.ffmpeg.operation.Type in project fmv by f-agu.
the class FilterComplexBase method addInput.
/**
* @param filterInput
* @param types
* @return
*/
public FilterComplexBase addInput(FilterInput filterInput, Type... types) {
if (filterInput == null) {
return this;
}
boolean inserted = false;
for (OutputKey outputKey : filterInput.getOutputKeys()) {
if (types.length == 0) {
inputMap.put(IOKey.of(outputKey), new In(filterInput));
inserted = true;
} else {
for (Type type : types) {
if (getTypes().contains(type) && outputKey.contains(type)) {
// System.out.println(filterInput + "/" + type + " --> " + this);
inputMap.put(IOKey.of(outputKey, type, hasExplicitType()), new In(filterInput, type));
inserted = true;
}
}
}
}
if (inserted && filterInput instanceof AbstractFilter) {
AbstractFilter filter = (AbstractFilter) filterInput;
InjectBuilder.inject(this, filter.operation);
}
return this;
}
use of org.fagu.fmv.ffmpeg.operation.Type in project fmv by f-agu.
the class FilterGraphUI method createOrGetNode.
/**
* @param filterComplex
* @return
*/
private Node createOrGetNode(FilterComplex filterComplex) {
String nodeKey = getNodeKey(filterComplex);
Node node = graph.getNode(nodeKey);
if (node == null) {
node = graph.addNode(nodeKey);
node.addAttribute("ui.label", nodeKey);
Collection<Type> types = filterComplex.getTypes();
String ccsStyle = null;
if (types.contains(Type.AUDIO) && !types.contains(Type.VIDEO)) {
ccsStyle = "audio";
} else if (!types.contains(Type.AUDIO) && types.contains(Type.VIDEO)) {
ccsStyle = "video";
}
if (ccsStyle != null) {
node.setAttribute("ui.class", ccsStyle);
}
}
return node;
}
Aggregations