use of org.fagu.fmv.ffmpeg.filter.FilterComplex in project fmv by f-agu.
the class AbstractOperation method toArguments.
/**
* @see org.fagu.fmv.ffmpeg.operation.Operation#toArguments()
*/
@Override
public List<String> toArguments() {
OperationListener operationListener = operationListener();
operationListener.eventPreToArguments(this);
List<String> arguments = new ArrayList<>();
// global
getGlobalParameters().toArguments(arguments);
// input
getInputParameters().toArguments(arguments);
// filter_complex
if (containsFilterComplexs()) {
List<FilterComplex> filterComplexs = getFilterComplexs();
arguments.add("-filter_complex");
StringBuilder fbuf = new StringBuilder();
Iterator<FilterComplex> it = filterComplexs.iterator();
boolean useLabels = autoMap.useLabels();
for (; ; ) {
FilterComplex f = it.next();
if (!useLabels) {
f.clearInput();
f.clearOutput();
}
fbuf.append(f.toString());
if (!it.hasNext()) {
break;
}
fbuf.append(';');
}
arguments.add(fbuf.toString());
if (!containsMap()) {
// auto-map
try {
for (Label label : autoMap.find(this)) {
arguments.add("-map");
arguments.add(filterNaming.generateBrackets(label));
}
} catch (RuntimeException e) {
throw new RuntimeException(arguments.toString(), e);
}
}
} else {
// filter
for (Type type : Type.values()) {
StringBuilder fbuf = new StringBuilder();
List<Filter> filterSimples = getFilterSimples(type);
if (!filterSimples.isEmpty()) {
Iterator<Filter> it = filterSimples.iterator();
for (; ; ) {
Filter f = it.next();
fbuf.append(f.toString());
if (!it.hasNext()) {
break;
}
fbuf.append(',');
}
String fstr = fbuf.toString();
if (StringUtils.isNotBlank(fstr)) {
arguments.add("-filter:" + type.code());
arguments.add(fstr);
}
}
}
}
// output
getOutputParameters().toArguments(arguments);
operationListener.eventPostToArguments(this);
return arguments;
}
Aggregations