Skip to content

Real time filters

Pedro Sánchez edited this page Mar 8, 2024 · 7 revisions

This library support OpenGL real time filters. By default you can choose between more than 40 different filters:

https://github.com/pedroSG94/RootEncoder/tree/master/encoder/src/main/java/com/pedro/encoder/input/gl/render/filters

If you want use this feature you need use the following constructors:

If you want add a filter to stream you only need use setFilter method. Example set gray scale filter:

rtmpCamera1.getGlInterface().setFilter(new GreyScaleFilterRender());

Multiple filters

Actually, it is working like if you are using a java ArrayList class with the following options:

  /**
   * Replaces the filter at the specified position with the specified filter.
   * You can modify filter's parameters after set it to stream.
   *
   * @param filterPosition filter position
   * @param baseFilterRender filter to set
   */
  void setFilter(int filterPosition, BaseFilterRender baseFilterRender);

  /**
   * Appends the specified filter to the end.
   * You can modify filter's parameters after set it to stream.
   *
   * @param baseFilterRender filter to add
   */
  void addFilter(BaseFilterRender baseFilterRender);

  /**
   * Inserts the specified filter at the specified position.
   * You can modify filter's parameters after set it to stream.
   *
   * @param filterPosition filter position
   * @param baseFilterRender filter to set
   */
  void addFilter(int filterPosition, BaseFilterRender baseFilterRender);

  /**
   * Remove all filters
   */
  void clearFilters();

  /**
   * Remove the filter at the specified position.
   *
   * @param filterPosition position of filter to remove
   */
  void removeFilter(int filterPosition);

  /**
   * @return number of filters
   */
  int filtersCount();

  /**
   * Replace the filter in position 0 or add the filter if list is empty.
   * You can modify filter's parameters after set it to stream.
   *
   * @param baseFilterRender filter to set.
   */
  void setFilter(BaseFilterRender baseFilterRender);

Create your own filter

You can do your own filter if you extend from BaseFilterRender class. I recommend you see GreyScaleFilterRender class that is an easy example in the library to know how to work it and create your own filter.

Clone this wiki locally