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 contrast


This recipe shows how to control the contrast feature of a video using the HTML5 filter feature. This is the second most important control that customers usually want to have when using video applications.

How to do it…

Follow the given steps:

  1. Add a control element to the main web page of your application—using this object we will change the contrast:

    Contrast
    <input type="range" oninput="changeContrast(this.valueAsNumber);" value="0" step="0.1" min="0" max="10">
  2. Add an appropriate JavaScript function:

    function changeContrast(val) {
      var v = document.getElementById("localVideo");
      v.style.webkitFilter="contrast(" + val + ")";
    };

    Here, localVideo is the ID property of the HTML video tag for the local video playback.

  3. Navigate your web browser to the web page. You will first see an unprocessed video from the web camera. The following screenshot depicts such a situation:

  4. On the left-hand side of the page, you can see a control described as Contrast. Try to move it to the...