Search in sources :

Example 1 with FilterGraph

use of org.fagu.fmv.ffmpeg.filter.graph.FilterGraph in project fmv by f-agu.

the class FilterGraphUI method show.

/**
 * @param builder
 */
public static void show(Operation<?, ?> operation) {
    FilterGraph filterGraph = operation.getFilterGraph();
    FilterGraphUI graphTest = new FilterGraphUI(operation, filterGraph);
    filterGraph.discover(() -> graphTest);
    graphTest.display();
}
Also used : FilterGraph(org.fagu.fmv.ffmpeg.filter.graph.FilterGraph)

Example 2 with FilterGraph

use of org.fagu.fmv.ffmpeg.filter.graph.FilterGraph in project fmv by f-agu.

the class AutoMaps method oneStreamByType.

/**
 * @param types
 * @return
 */
public static AutoMap oneStreamByType(Set<Type> types, FilterNaming filterNaming) {
    return new AutoMap() {

        @Override
        public boolean useLabels() {
            return true;
        }

        @Override
        public Set<Label> find(Operation<?, ?> operation) {
            FilterGraph filterGraph = FilterGraph.of(operation);
            // filterGraph.discover(() -> Visitors.checkSameTypes());
            MapSet<Label, Type> mapSet = MultiValueMaps.hashMapHashSet();
            filterGraph.discover(() -> Visitors.lastLabelWithType(mapSet));
            Map<Type, Label> chdirMap = new HashMap<>(4);
            for (Entry<Label, Set<Type>> entry : mapSet.entrySet()) {
                for (Type type : entry.getValue()) {
                    if (chdirMap.putIfAbsent(type, entry.getKey()) != null) {
                        throw new RuntimeException("Type " + type + " already defined in an other output filter: " + mapSet);
                    }
                }
            }
            for (Type type : types) {
                // missing some types ?
                if (!chdirMap.containsKey(type)) {
                    InputParameters inputParameters = operation.getInputParameters();
                    for (IOEntity ioEntity : inputParameters.getIOEntities()) {
                        Processor<?> processor = inputParameters.getProcessor(ioEntity);
                        if (processor instanceof InputProcessor) {
                            try {
                                MovieMetadatas movieMetadatas = ((InputProcessor) processor).getMovieMetadatas();
                                if (movieMetadatas.contains(type)) {
                                    chdirMap.put(type, Label.input(processor.getIndex(), type));
                                    break;
                                }
                            } catch (Exception e) {
                                throw new RuntimeException(e);
                            }
                        }
                    }
                }
            }
            return new HashSet<>(chdirMap.values());
        }
    };
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) MapSet(org.fagu.fmv.utils.collection.MapSet) HashMap(java.util.HashMap) Label(org.fagu.fmv.ffmpeg.filter.Label) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) FilterGraph(org.fagu.fmv.ffmpeg.filter.graph.FilterGraph) HashSet(java.util.HashSet)

Aggregations

FilterGraph (org.fagu.fmv.ffmpeg.filter.graph.FilterGraph)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Label (org.fagu.fmv.ffmpeg.filter.Label)1 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)1 MapSet (org.fagu.fmv.utils.collection.MapSet)1