Book Image

WebRTC Cookbook

By : Andrii Sergiienko
Book Image

WebRTC Cookbook

By: Andrii Sergiienko

Overview of this book

Table of Contents (15 chapters)
WebRTC Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with hue


In this recipe, we will learn how to control the video's hue. Usually, you will not use this filter in your applications, although, sometimes it might be helpful; for example when you're using some kind of specific video equipment that might need this way of processing video.

How to do it…

Follow the given steps:

  1. Add a control element to the application's main web page—using this object we will change the video's hue:

    Hue
    <input type="range" oninput="changeHue(this.valueAsNumber);" value="0" step="20" min="0" max="360">

    Here, you can see that we have set the max value as 360—this is because the hue's value is tied to degrees. In this universe, we have 360 degrees, so the maximum value for this filter is set to 360.

  2. Add an appropriate JavaScript function:

    function changeHue(val) {
      var v = document.getElementById("localVideo");
      v.style.webkitFilter="hue-rotate(" + val + "deg)";
    };

    We have also added the deg postfix to the filter's value—it means degree. Here, localVideo...