use of org.fagu.fmv.core.exec.Executable in project fmv by f-agu.
the class BasePrompt method get.
/**
* @see org.fagu.fmv.cli.Prompt#get(org.fagu.fmv.cli.Environnement)
*/
@Override
public String get(Environnement environnement) {
Executable currentExecutable = environnement.getCurrentExecutable();
StringBuilder prompt = new StringBuilder(50);
if (currentExecutable != null) {
prompt.append(currentExecutable.getCode()).append('[').append(currentExecutable.getId()).append(']');
}
prompt.append("# ");
return prompt.toString();
}
use of org.fagu.fmv.core.exec.Executable in project fmv by f-agu.
the class Console method startConsole.
/**
* @param consoleReader
* @throws IOException
*/
private void startConsole(ConsoleReader consoleReader) throws IOException {
List<Executable> executables = project.getExecutables();
if (!executables.isEmpty()) {
return;
}
consoleReader.println("Create a default structure");
GenericExecutable rootExec = new GenericExecutable(project);
FadeAudioVideoFilterExec fadeOut = new FadeAudioVideoFilterExec(project, FadeType.OUT, Time.valueOf(200), Duration.valueOf(3));
rootExec.add(fadeOut);
FadeAudioVideoFilterExec fadeIn = new FadeAudioVideoFilterExec(project, FadeType.IN, Time.valueOf(0), Duration.valueOf(2));
fadeOut.add(fadeIn);
GenericFilterExec audioMerge = new GenericFilterExec(project, "amerge");
fadeIn.add(audioMerge);
ConcatExecutable concat = new ConcatExecutable(project);
audioMerge.add(concat);
project.modified();
}
use of org.fagu.fmv.core.exec.Executable in project fmv by f-agu.
the class Project method saveExecutables.
/**
* @param root
*/
private void saveExecutables(Element root) {
for (Executable executable : getExecutables()) {
Element execElement = root.addElement("exec");
executable.save(execElement);
}
}
use of org.fagu.fmv.core.exec.Executable in project fmv by f-agu.
the class CutExecutable method execute.
/**
* @see org.fagu.fmv.core.exec.Executable#execute(java.io.File, Cache)
*/
@Override
public void execute(File toFile, Cache cache) throws IOException {
Source source = getSource();
Executable executable = getExecutable();
if (executable == null && source == null) {
return;
}
OutputInfos outputInfos = getProject().getOutputInfos();
FFMPEGExecutorBuilder builder = FFUtils.builder(getProject());
InputProcessor inputProcessor = null;
if (executable != null) {
File childExec = getProject().getFileCache().getFile(executable, cache);
// executable.execute(childExec, cache);
inputProcessor = builder.addMediaInputFile(childExec);
} else if (source != null) {
inputProcessor = (InputProcessor) source.createAndAdd(builder);
} else {
throw new IllegalArgumentException("Source or executable not defined !");
}
inputProcessor.timeSeek(startTime);
// SetPTS videoSetPTS = new SetPTSVideo();
// videoSetPTS.setStartAtFirstFrame();
// FilterComplex videoSetPTSComplex = FilterComplex.createWith(videoSetPTS);
// videoSetPTSComplex.addInput(inputProcessor, Type.VIDEO);
// builder.add(videoSetPTSComplex);
//
// SetPTS audioSetPTS = new SetPTSAudio();
// audioSetPTS.setStartAtFirstFrame();
// FilterComplex audioSetPTSComplex = FilterComplex.createWith(audioSetPTS);
// audioSetPTSComplex.addInput(inputProcessor, Type.AUDIO);
// builder.add(audioSetPTSComplex);
BasicStreamMuxer muxer = BasicStreamMuxer.to(toFile, outputInfos.getFormat()).avoidNegativeTs(AvoidNegativeTs.MAKE_NON_NEGATIVE);
OutputProcessor outputProcessor = builder.mux(muxer);
outputProcessor.duration(duration);
outputProcessor(outputProcessor, cache);
FFExecutor<Object> executor = builder.build();
executor.execute();
if (cache == Cache.MAKE) {
MovieMetadatas movieMetadatas = MovieMetadatas.with(toFile).extract();
MovieMetadatasUtils.getDuration(movieMetadatas).ifPresent(this::setDuration);
}
}
use of org.fagu.fmv.core.exec.Executable in project fmv by f-agu.
the class AudioMixExecutable method execute.
/**
* @see org.fagu.fmv.core.exec.Executable#execute()
*/
@Override
public void execute(File toFile, Cache cache) throws IOException {
if (!hasChildren()) {
return;
}
AudioMix audioMix = AudioMix.build();
FFMPEGExecutorBuilder builder = FFUtils.builder(getProject());
List<InputProcessor> inputProcessors = new ArrayList<>();
// executable
for (Executable executable : executables) {
File file = getProject().getFileCache().getFile(executable, cache);
InputProcessor inputProcessor = builder.addMediaInputFile(file);
// audioMix.addInput(inputProcessor);
inputProcessors.add(inputProcessor);
}
// source
for (Source source : sources) {
FilterInput filterInput = source.createAndAdd(builder);
if (filterInput instanceof InputProcessor) {
inputProcessors.add((InputProcessor) filterInput);
// MovieMetadatas movieMetadatas = ((InputProcessor)filterInput).getMovieMetadatas();
// if(movieMetadatas.contains(Type.AUDIO)) {
// audioMix.addInput(filterInput, audioStart);
// } else {
// throw new RuntimeException("Source is not an audio stream: " + source);
// }
} else {
throw new RuntimeException("Source is not a InputProcessor: " + source);
}
}
List<InputProcessor> videoInputProcessors = new ArrayList<>();
for (InputProcessor inputProcessor : inputProcessors) {
MovieMetadatas movieMetadatas = inputProcessor.getMovieMetadatas();
if (movieMetadatas.contains(Type.AUDIO) && !movieMetadatas.contains(Type.VIDEO)) {
audioMix.addInput(inputProcessor, audioStart);
} else {
videoInputProcessors.add(inputProcessor);
audioMix.addInput(inputProcessor);
}
}
audioMix.duration(mixAudioDuration);
OutputProcessor outputProcessor = outputProcessor(builder, toFile, cache);
ObjectInvoker.invoke(outputProcessor, attributeMap);
builder.filter(audioMix);
Map map = outputProcessor.map();
map.allStreams().input(audioMix);
On videoStreams = map.types(Type.VIDEO);
videoInputProcessors.stream().forEach(videoStreams::input);
FFExecutor<Object> executor = builder.build();
executor.execute();
}
Aggregations