Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
242 lines (187 sloc) 10.1 KB

Voice and video filters

OpenVidu API offers a simple way of applying filters to video and audio streams in the server side by making use of Kurento Media Server capabilities. This is the current status of filter support in OpenVidu:

  • You can apply one filter at a time to a published Stream. Every user subscribed to it will receive the modified stream.
  • You can remove an applied filter.
  • You can call any remote method offered by an applied filter
  • You can add and remove event listeners to any event dispatched by an applied filter.
  • You must configure in the participant token the allowed filters the user can apply.
WARNING: experimental option. This feature may suffer breaking changes in the near future.

Step by step

##### 1) Generate a token with the filters the user will be able to apply

This is a simple way of securing the ability of applying filters from OpenVidu Browser, so that not every user is able to apply any filter at any time.

  • API REST: include in the JSON body a parameter kurentoOptions with a property allowedFilters (a string array containing the name of the filters the user will be able to apply)

          "session": "6fpivlanw91qjy6n",
          "data": "user_data",
          "role": "PUBLISHER",
          "kurentoOptions": {
    	        "allowedFilters": ["GStreamerFilter", "FaceOverlayFilter"]
  • openvidu-java-client: call TokenOptions.Builder#kurentoOptions(KurentoOptions) to set allowedFilters value with method KurentoOptions.Builder#allowedFilters(String[])

      TokenOptions tokenOptions = new TokenOptions.Builder()
              new KurentoOptions.Builder()
                  .allowedFilters(new String[]{"GStreamerFilter", "FaceOverlayFilter"})
      String token = session.generateToken(tokenOptions);
  • openvidu-node-client: include in TokenOptions parameter a kurentoOptions property with allowedFiters array

      var tokenOptions = {
          role: "PUBLISHER",
          data: "user_data",
          kurentoOptions: {
    	        allowedFilters: ["GStreamerFilter", "FaceOverlayFilter"]
      session.generateToken(tokenOptions).then(token => { ... });

##### 2.A) Initialize a Publisher object configured for using a filter from the beginning of the publishing ...

Use PublisherProperties, specifically property filter:

var OV = new OpenVidu();
var publisher = OV.initPublisher(
    {filter: {type: "GStreamerFilter", options: "videoflip method=vertical-flip"}}

// ... user already connected to "session" with the appropriate token

##### 2.B) ... or apply the filter dynamically after publishing the stream, whenever you want
// ... user already connected to the session with the appropriate token
// and successfully publishing the Publisher object"GStreamerFilter", "videoflip method=vertical-flip")
    .then(() => {
        console.log("Video rotated!");
    .catch(error => {

##### 3) You can execute any method offered by the filter
// ... user already connected to the session with the appropriate token,
// successfully publishing the Publisher object and a filter being applied to its stream"setElementProperty", {"propertyName":"method","propertyValue":"horizontal-flip"})
    .then(() => {
        console.log("Video rotation direction modified!");
    .catch(error => {

##### 4) You can also subscribe to any filter event (if it dispatches any), and later unsubscribe from it
// ... user already connected to the session with the appropriate token,
// successfully publishing the Publisher object and a filter being applied to its stream"FooFilterEvent", filterEvent => {
        console.log('Filter event received!. Data: ' +;


##### 4) To remove the filter
// ... user already connected to the session with the appropriate token,
// successfully publishing the Publisher object and a filter being applied to its stream
    .then(() => {
        console.log("Filter removed");
    .catch(error => {

Moderators are not only able to call all of these methods over their object, but also over any object. Also, they don't need any special token permission to apply filters and can bypass any token restriction set to other user tokens

Filter samples

Kurento filters

  • FaceOverlayFilter (overlay an image over detected faces)"FaceOverlayFilter")
          .then(filter => {

  • ChromaFilter (set a chroma background)
              "window": {
                  "topRightCornerX": 0,
                  "topRightCornerY": 0,
                  "width": 50,
                  "height": 50
              "backgroundImage": ""

You must install Kurento ChromaFilter library in the same host as Kurento Media Server: sudo apt-get install kms-chroma

  • ZBarFilter (detect and read bar codes information)"ZBarFilter")
          .then(filter => {
              filter.addEventListener("CodeFound", filterEvent => {
                  console.log('Bar code found!. Data: ' +;

GStreamer filters

These filters are set with type GStreamerFilter and an options parameter like this:"GStreamerFilter", {"command": "GSTREAMER_COMMAND"})

A list of interesting values for GSTREAMER_COMMAND parameter is stated below. Replace GSTREAMER_COMMAND in the upper code snippet for any of the examples provided in the following list items:

  • coloreffects: apply different color filters to the video stream
    Example: coloreffects preset=heat
  • videobalance: change different properties of the video stream such as brightness, contrast, hue or saturation
    Example: videobalance saturation=0.0
  • videoflip: rotate the video stream
    Example: videoflip method=vertical-flip
  • videobox: crop the video stream
    Example: videobox fill=black top=20 bottom=20 left=-10 right=-10
  • gamma: adjust gamma level of the video stream
    Example: gamma gamma=5.0
  • videomedian: add a median filter to the video stream
    Example: videomedian filtersize=9 lum-only=false
  • textoverlay: add an embedded text to the video
    Example: textoverlay text="Embedded text" valignment=top halignment=right font-desc="Cantarell 25"
  • timeoverlay: embed the time the video stream has been playing
    Example: timeoverlay valignment=bottom halignment=right font-desc="Sans, 20"
  • clockoverlay: embed a clock with the local time (in OpenVidu Server)
    Example: clockoverlay valignment=bottom halignment=right shaded-background=true font-desc="Sans, 20"
  • audioecho: add reverb to the audio stream
    Example: audioecho delay=50000000 intensity=0.6 feedback=0.4
  • audioamplify: amplifies an audio stream by a given factor
    Example: audioamplify amplification=1.5 clipping-method=wrap-positive
  • Other audio filters: check them out in GStreamer site
  • Many effects of effectv project : funny filters for the video stream like agingtv, dicetv, optv, quarktv, radioactv, revtv, rippletv, shagadelictv, streaktv, vertigotv, warptv
    Example: radioactv

All available GStreamer plugins can be found in GStreamer site.