public static FrameFilter createDefault(String filtersDescr, int imageWidth, int imageHeight) throws Exception { return new FFmpegFrameFilter(filtersDescr, imageWidth, imageHeight); }
/** * Constructs a filtergraph out of the filter specification. * * @param filters to use * @param width of the input images * @param height of the input images * @param channels of the input images */ public FilterImageTransform(String filters, int width, int height, int channels) { super(null); int pixelFormat = channels == 1 ? AV_PIX_FMT_GRAY8 : channels == 3 ? AV_PIX_FMT_BGR24 : channels == 4 ? AV_PIX_FMT_RGBA : AV_PIX_FMT_NONE; if (pixelFormat == AV_PIX_FMT_NONE) { throw new IllegalArgumentException("Unsupported number of channels: " + channels); } try { filter = new FFmpegFrameFilter(filters, width, height); filter.setPixelFormat(pixelFormat); filter.start(); } catch (FrameFilter.Exception e) { throw new RuntimeException(e); } }
/** * Constructs a filtergraph out of the filter specification. * * @param filters to use * @param width of the input images * @param height of the input images * @param channels of the input images */ public FilterImageTransform(@JsonProperty("filters") String filters, @JsonProperty("width") int width, @JsonProperty("height") int height, @JsonProperty("channels") int channels) { super(null); this.filters = filters; this.width = width; this.height = height; this.channels = channels; int pixelFormat = channels == 1 ? AV_PIX_FMT_GRAY8 : channels == 3 ? AV_PIX_FMT_BGR24 : channels == 4 ? AV_PIX_FMT_RGBA : AV_PIX_FMT_NONE; if (pixelFormat == AV_PIX_FMT_NONE) { throw new IllegalArgumentException("Unsupported number of channels: " + channels); } try { filter = new FFmpegFrameFilter(filters, width, height); filter.setPixelFormat(pixelFormat); filter.start(); } catch (FrameFilter.Exception e) { throw new RuntimeException(e); } }