use of org.fagu.fmv.ffmpeg.filter.Filter 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.filter.Filter 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.filter.Filter 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.filter.Filter in project fmv by f-agu.
the class Libx264NotDisibleBy2FFExecFallback method prepare.
/**
* @see org.fagu.fmv.ffmpeg.executor.FFExecFallback#prepare(org.fagu.fmv.ffmpeg.executor.FFEnv, java.io.IOException)
*/
@Override
public boolean prepare(FFEnv ffEnv, IOException ioException) throws IOException {
FFExecutor<Object> executor = ffEnv.getExecutor();
AbstractOperation<?, ?> operation = (AbstractOperation<?, ?>) ffEnv.getOperation();
for (String line : executor.getOutputReadLine().getLines()) {
if (line.startsWith("[libx264 @") && line.contains(" not divisible by 2")) {
for (Filter filter : operation.getFilters()) {
if (filter instanceof Scale) {
Scale scale = (Scale) filter;
Size size = scale.getSize();
ScaleMode scaleMode = scale.getScaleMode();
if (size != null && scaleMode != null) {
Size newSize = resize(size);
if (newSize == null) {
return false;
}
scale.set(size, scaleMode);
return true;
}
}
}
}
}
return false;
}
use of org.fagu.fmv.ffmpeg.filter.Filter in project fmv by f-agu.
the class Concat method addPTS.
// ****************************************************
/**
* @param builder
* @param setPTS
* @param input
*/
private void addPTS(FFMPEGExecutorBuilder builder, SetPTS<?> setPTS, Object input) {
setPTS.startAtFirstFrame();
FilterComplex setPTSComplex = FilterComplex.create(setPTS);
setPTSComplex.addInput((FilterInput) input, setPTS.getTypes().iterator().next());
if (input instanceof Filter) {
builder.filter((Filter) input);
}
builder.filter(setPTSComplex);
super.addInput(setPTSComplex);
}
Aggregations