use of org.fagu.fmv.ffmpeg.filter.Filter in project fmv by f-agu.
the class GenericExecutable method populateWithIdentifiables.
// *******************************************************
/**
* @param toFile
* @param cache
* @param builder
*/
protected List<FilterInput> populateWithIdentifiables(File toFile, Cache cache, FFMPEGExecutorBuilder builder) {
List<FilterInput> filterInputs = new ArrayList<>();
// executable
for (Executable executable : executables) {
File file = getProject().getFileCache().getFile(executable, cache);
filterInputs.add(builder.addMediaInputFile(file));
}
// source
for (Source source : sources) {
filterInputs.add(source.createAndAdd(builder));
}
// filters
for (FilterExec filterExec : getFilters()) {
Filter filter = filterExec.makeFilter(builder, cache);
builder.filter(filter);
if (filter instanceof FilterComplexBase) {
filterInputs.add((FilterComplexBase) filter);
}
}
return filterInputs;
}
use of org.fagu.fmv.ffmpeg.filter.Filter in project fmv by f-agu.
the class AbstractOperation method add.
/**
* @see org.fagu.fmv.ffmpeg.operation.Operation#add(Filter)
*/
@Override
public boolean add(Filter filter) {
if (rawFilters.contains(filter)) {
return false;
}
OperationListener operationListener = operationListener();
operationListener.eventPreAddFilter(this, filter);
addRawFilter(filter);
if (filter instanceof FilterComplexBase) {
if (!containsFilterComplex) {
containsFilterComplex = true;
List<Filter> newFilters = new ArrayList<>();
for (Filter f : filters) {
FilterComplex fc = FilterComplex.create(f);
newFilters.add(fc);
addRawFilter(fc);
}
filters = newFilters;
}
filters.add(filter);
} else {
if (containsFilterComplex) {
FilterComplex fc = FilterComplex.create(filter);
filters.add(fc);
addRawFilter(fc);
} else {
filters.add(filter);
}
}
if (filter instanceof LibLog) {
libLogs.add((LibLog) filter);
}
operationListener.eventPostAddFilter(this, filter);
return true;
}
use of org.fagu.fmv.ffmpeg.filter.Filter 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