Search in sources :

Example 6 with Executable

use of org.fagu.fmv.core.exec.Executable in project fmv by f-agu.

the class Append method getConcatExecutable.

// ********************************************
/**
 * @return
 */
private ConcatExecutable getConcatExecutable() {
    Executable currentExecutable = environnement.getCurrentExecutable();
    if (currentExecutable != null && currentExecutable instanceof ConcatExecutable) {
        return (ConcatExecutable) currentExecutable;
    }
    List<ConcatExecutable> execs = BaseIdentifiable.stream(project).filter(id -> id instanceof ConcatExecutable).map(id -> (ConcatExecutable) id).collect(Collectors.toList());
    int size = execs.size();
    if (size == 0) {
        return new ConcatExecutable(project);
    }
    if (size == 1) {
        return execs.get(0);
    }
    Printer printer = getPrinter();
    printer.println("Too many executable.");
    printer.println("List all executables: execlist");
    printer.println("And select one: toexecutable <id>");
    return null;
}
Also used : Printer(org.fagu.fmv.cli.utils.Printer) CutExecutable(org.fagu.fmv.core.exec.executable.CutExecutable) ConcatExecutable(org.fagu.fmv.core.exec.executable.ConcatExecutable) Duration(org.fagu.fmv.utils.time.Duration) Collectors(java.util.stream.Collectors) Executable(org.fagu.fmv.core.exec.Executable) Command(org.fagu.fmv.cli.annotation.Command) List(java.util.List) Alias(org.fagu.fmv.cli.annotation.Alias) SourceSource(org.fagu.fmv.core.exec.source.SourceSource) Time(org.fagu.fmv.utils.time.Time) GenericExecutable(org.fagu.fmv.core.exec.executable.GenericExecutable) FileSource(org.fagu.fmv.core.project.FileSource) BaseIdentifiable(org.fagu.fmv.core.exec.BaseIdentifiable) ConcatExecutable(org.fagu.fmv.core.exec.executable.ConcatExecutable) CutExecutable(org.fagu.fmv.core.exec.executable.CutExecutable) ConcatExecutable(org.fagu.fmv.core.exec.executable.ConcatExecutable) Executable(org.fagu.fmv.core.exec.Executable) GenericExecutable(org.fagu.fmv.core.exec.executable.GenericExecutable) Printer(org.fagu.fmv.cli.utils.Printer)

Example 7 with Executable

use of org.fagu.fmv.core.exec.Executable in project fmv by f-agu.

the class ConcatFadeExecutable method execute.

/**
 * @see org.fagu.fmv.core.exec.Executable#execute()
 */
@Override
public void execute(File toFile, Cache cache) throws IOException {
    if (!hasChildren()) {
        return;
    }
    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);
        }
    }
    applyConcatFade(builder, inputProcessors, toFile, cache);
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) FilterInput(org.fagu.fmv.ffmpeg.filter.FilterInput) ArrayList(java.util.ArrayList) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) Executable(org.fagu.fmv.core.exec.Executable) File(java.io.File) Source(org.fagu.fmv.core.exec.Source)

Example 8 with Executable

use of org.fagu.fmv.core.exec.Executable 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;
}
Also used : FilterExec(org.fagu.fmv.core.exec.FilterExec) Filter(org.fagu.fmv.ffmpeg.filter.Filter) FilterInput(org.fagu.fmv.ffmpeg.filter.FilterInput) ArrayList(java.util.ArrayList) FilterComplexBase(org.fagu.fmv.ffmpeg.filter.FilterComplexBase) Executable(org.fagu.fmv.core.exec.Executable) File(java.io.File) Source(org.fagu.fmv.core.exec.Source)

Example 9 with Executable

use of org.fagu.fmv.core.exec.Executable in project fmv by f-agu.

the class Make method run.

/**
 * @see org.fagu.fmv.cli.Command#run(java.lang.String[])
 */
@Override
public void run(String[] args) {
    List<Executable> executables = project.getExecutables();
    if (executables.isEmpty()) {
        return;
    }
    File file = project.getFileCache().getFile(executables.get(0), Cache.MAKE);
    System.out.println(file);
    OpenFile openFile = new OpenFile(fmvCliConfig, getPrinter());
    openFile.open(file, FileType.VIDEO);
}
Also used : OpenFile(org.fagu.fmv.cli.utils.OpenFile) Executable(org.fagu.fmv.core.exec.Executable) OpenFile(org.fagu.fmv.cli.utils.OpenFile) File(java.io.File)

Example 10 with Executable

use of org.fagu.fmv.core.exec.Executable in project fmv by f-agu.

the class Preview method run.

/**
 * @see org.fagu.fmv.cli.Command#run(java.lang.String[])
 */
@Override
public void run(String[] args) {
    List<Executable> executables = project.getExecutables();
    if (executables.isEmpty()) {
        return;
    }
    File file = project.getFileCache().getFile(executables.get(0), Cache.PREVIEW);
    System.out.println(file);
    OpenFile openFile = new OpenFile(fmvCliConfig, getPrinter());
    openFile.open(file, FileType.VIDEO);
}
Also used : OpenFile(org.fagu.fmv.cli.utils.OpenFile) Executable(org.fagu.fmv.core.exec.Executable) OpenFile(org.fagu.fmv.cli.utils.OpenFile) File(java.io.File)

Aggregations

Executable (org.fagu.fmv.core.exec.Executable)11 File (java.io.File)6 Source (org.fagu.fmv.core.exec.Source)4 ArrayList (java.util.ArrayList)3 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)3 FilterInput (org.fagu.fmv.ffmpeg.filter.FilterInput)3 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)3 OpenFile (org.fagu.fmv.cli.utils.OpenFile)2 BaseIdentifiable (org.fagu.fmv.core.exec.BaseIdentifiable)2 ConcatExecutable (org.fagu.fmv.core.exec.executable.ConcatExecutable)2 GenericExecutable (org.fagu.fmv.core.exec.executable.GenericExecutable)2 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)2 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Element (org.dom4j.Element)1 Alias (org.fagu.fmv.cli.annotation.Alias)1 Command (org.fagu.fmv.cli.annotation.Command)1 Printer (org.fagu.fmv.cli.utils.Printer)1 FilterExec (org.fagu.fmv.core.exec.FilterExec)1