Search in sources :

Example 1 with Identifiable

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

the class FadeAudioVideo method run.

/**
 * @see org.fagu.fmv.cli.Command#run(java.lang.String[])
 */
@Override
public void run(String[] args) {
    if (args.length != 4) {
        help();
        return;
    }
    // TEST
    Optional<Identifiable> identifiableOpt = BaseIdentifiable.findById(project, args[1]);
    if (!identifiableOpt.isPresent()) {
        println("not found: " + args[1]);
        return;
    }
    FadeType fadeType = FadeType.valueOf(args[0].toUpperCase());
    Time startTime = Time.parse(args[2]);
    Duration duration = Duration.parse(args[2]);
    Identifiable identifiable = identifiableOpt.get();
    FadeAudioVideoFilterExec filterExec = new FadeAudioVideoFilterExec(project, fadeType, startTime, duration);
    filterExec.add(identifiable);
}
Also used : Time(org.fagu.fmv.utils.time.Time) Duration(org.fagu.fmv.utils.time.Duration) FadeAudioVideoFilterExec(org.fagu.fmv.core.exec.filter.FadeAudioVideoFilterExec) FadeType(org.fagu.fmv.ffmpeg.filter.impl.FadeType) Identifiable(org.fagu.fmv.core.exec.Identifiable) BaseIdentifiable(org.fagu.fmv.core.exec.BaseIdentifiable)

Example 2 with Identifiable

use of org.fagu.fmv.core.exec.Identifiable 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;
}
Also used : FilterExec(org.fagu.fmv.core.exec.FilterExec) Type(org.fagu.fmv.ffmpeg.operation.Type) Filter(org.fagu.fmv.ffmpeg.filter.Filter) FilterInput(org.fagu.fmv.ffmpeg.filter.FilterInput) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) File(java.io.File) HashSet(java.util.HashSet) Identifiable(org.fagu.fmv.core.exec.Identifiable)

Example 3 with Identifiable

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

the class ExecList method displayIdentifiable.

// *******************************************************
/**
 * @param identifiables
 * @param paddingSize
 */
private void displayIdentifiable(List<? extends Identifiable> identifiables, int paddingSize) {
    for (Identifiable identifiable : identifiables) {
        StringBuilder buf = new StringBuilder(100);
        buf.append(StringUtils.rightPad(identifiable.getId(), ID_WIDTH));
        buf.append(StringUtils.rightPad(typesToString(identifiable.getTypes()), TYPE_WIDTH));
        buf.append(StringUtils.rightPad(identifiable.getDuration().flatMap(d -> Optional.of(d == null ? "-" : d.toString())).get(), TIME_WIDTH));
        buf.append(StringUtils.leftPad("", paddingSize));
        buf.append(identifiable.toString());
        println(buf.toString());
        displayIdentifiable(identifiable.getIdentifiableChildren(), paddingSize + 3);
    }
}
Also used : Command(org.fagu.fmv.cli.annotation.Command) List(java.util.List) Alias(org.fagu.fmv.cli.annotation.Alias) Identifiable(org.fagu.fmv.core.exec.Identifiable) Optional(java.util.Optional) Set(java.util.Set) Type(org.fagu.fmv.ffmpeg.operation.Type) StringUtils(org.apache.commons.lang3.StringUtils) Identifiable(org.fagu.fmv.core.exec.Identifiable)

Example 4 with Identifiable

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

the class ToExecutable method run.

/**
 * @see org.fagu.fmv.cli.Command#run(java.lang.String[])
 */
@Override
public void run(String[] args) {
    if (args.length != 1) {
        help();
        return;
    }
    String id = args[0];
    if (".".equals(id)) {
        environnement.setCurrentExecutable(null);
        return;
    }
    Optional<Identifiable> opt = BaseIdentifiable.findById(project, id);
    if (!opt.isPresent()) {
        println("ID not found: " + id);
        return;
    }
    Identifiable identifiable = opt.get();
    if (!(identifiable instanceof Executable)) {
        println("ID is not an executable: " + id);
        return;
    }
    Executable executable = (Executable) identifiable;
    environnement.setCurrentExecutable(executable);
}
Also used : Executable(org.fagu.fmv.core.exec.Executable) Identifiable(org.fagu.fmv.core.exec.Identifiable) BaseIdentifiable(org.fagu.fmv.core.exec.BaseIdentifiable)

Aggregations

Identifiable (org.fagu.fmv.core.exec.Identifiable)4 BaseIdentifiable (org.fagu.fmv.core.exec.BaseIdentifiable)2 Type (org.fagu.fmv.ffmpeg.operation.Type)2 File (java.io.File)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Alias (org.fagu.fmv.cli.annotation.Alias)1 Command (org.fagu.fmv.cli.annotation.Command)1 Executable (org.fagu.fmv.core.exec.Executable)1 FilterExec (org.fagu.fmv.core.exec.FilterExec)1 FadeAudioVideoFilterExec (org.fagu.fmv.core.exec.filter.FadeAudioVideoFilterExec)1 Filter (org.fagu.fmv.ffmpeg.filter.Filter)1 FilterInput (org.fagu.fmv.ffmpeg.filter.FilterInput)1 FadeType (org.fagu.fmv.ffmpeg.filter.impl.FadeType)1 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)1 Duration (org.fagu.fmv.utils.time.Duration)1 Time (org.fagu.fmv.utils.time.Time)1