use of org.fagu.fmv.ffmpeg.filter.OutputKey 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.filter.OutputKey in project fmv by f-agu.
the class FilterGraph method discover.
// ***************************************************
/**
* @param inLabel
* @param filterComplex
* @param outLabel
* @param visitor
* @param depth
*/
private <T> void discover(Label inLabel, FilterComplex filterComplex, Visitor<T> visitor, int depth) {
for (OutputKey outputKey : filterComplex.getOutputKeys()) {
Label outLabel = outputKey.getLabel();
Set<FilterComplex> inFilters = null;
if (inLabel != null) {
inFilters = byOutMap.get(inLabel);
}
Set<FilterComplex> outFilters = byInMap.get(outLabel);
visitor.visit(inLabel, inFilters, filterComplex, outFilters, outLabel, depth);
if (outFilters != null) {
for (FilterComplex childFC : outFilters) {
discover(outLabel, childFC, visitor, depth + 1);
}
}
}
}
use of org.fagu.fmv.ffmpeg.filter.OutputKey in project fmv by f-agu.
the class FFHelper method splitTo3.
/**
* @param inFile
* @param outFile1
* @param outFile2
* @throws IOException
*/
public static void splitTo3(File inFile, File outFile1, File outFile2, File outFile3) throws IOException {
// outFile1 : no fade
// outFile2 : fade in
// outFile3 : fade out
FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
InputProcessor inputProcessor = builder.addMediaInputFile(inFile);
SplitVideo splitVideo = SplitVideo.build();
splitVideo.addInput(inputProcessor);
OutputKey outv1 = splitVideo.addOutput();
OutputKey outv2 = splitVideo.addOutput();
OutputKey outv3 = splitVideo.addOutput();
SplitAudio splitAudio = SplitAudio.build();
splitAudio.addInput(inputProcessor);
OutputKey outa1 = splitAudio.addOutput();
OutputKey outa2 = splitAudio.addOutput();
OutputKey outa3 = splitAudio.addOutput();
Fade fade2 = Fade.create(FadeType.IN, Time.valueOf(0), Duration.valueOf(1));
Fade fade3 = Fade.create(FadeType.OUT, Time.valueOf(0), Duration.valueOf(1));
fade2.addInput(outv2).addInput(outa2);
fade3.addInput(outv3).addInput(outa3);
builder.filter(splitVideo);
builder.filter(splitAudio);
builder.filter(fade2);
builder.filter(fade3);
OutputProcessor outputProcessor1 = builder.addMediaOutputFile(outFile1);
outputProcessor1.map().allStreams().label(outv1.getLabel()).label(outa1.getLabel());
outputProcessor1.overwrite();
OutputProcessor outputProcessor2 = builder.addMediaOutputFile(outFile2);
outputProcessor2.map().allStreams().input(fade2);
outputProcessor2.overwrite();
OutputProcessor outputProcessor3 = builder.addMediaOutputFile(outFile3);
outputProcessor3.map().allStreams().input(fade3);
outputProcessor3.overwrite();
FFExecutor<Object> executor = builder.build();
executor.execute();
}
use of org.fagu.fmv.ffmpeg.filter.OutputKey in project fmv by f-agu.
the class FilterGraphUI method addRoot.
// **************************************************
/**
*/
private void addRoot() {
Map<InputProcessor, Node> inputProcessorNodeMap = new HashMap<>();
operation.getInputProcessorStream().forEach(ip -> {
for (OutputKey outputKey : ip.getOutputKeys()) {
Node node = createRootNode(ip, outputKey);
inputProcessorNodeMap.put(ip, node);
}
});
for (FilterComplex rootFC : filterGraph.getRoots()) {
Map<IOKey, In> inputMap = rootFC.getInputMap();
if (!inputMap.isEmpty()) {
for (Entry<IOKey, In> entry : inputMap.entrySet()) {
FilterInput filterInput = entry.getValue().getFilterInput();
if (filterInput instanceof InputProcessor) {
Node node = inputProcessorNodeMap.get(filterInput);
Edge edge = graph.addEdge(node.getId() + "-" + rootFC.toString(), createOrGetNode(rootFC), node);
// edge.addAttribute("ui.label", values);
}
}
}
}
}
Aggregations