WebVfx 0.1.6-6-g5144893-dirty
examples/filter-demo.html

This is an example MLT filter implemented in HTML. It renders the video into an HTML canvas with a circle clip applied. The rendered video can be viewed here demo/mlt/mlt_filter_demo_html.

<html>
<head>
<style type="text/css">
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
}
</style>
<script type="text/javascript">
function Filter() {
    // Create a canvas
    var canvas = document.createElement('canvas');
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    document.body.appendChild(canvas);
    this.context = canvas.getContext('2d');

    // Clip video to a circle in the middle of the canvas
    var radius = webvfx.getNumberParameter("radius");
    if (!radius)
        radius = 0.5;
    this.context.beginPath();
    this.context.arc(canvas.width/2, canvas.height/2,
                     canvas.height * radius, 0, Math.PI*2, true)
    this.context.clip();

    this.image = new Image();
}

Filter.prototype.render = function(time) {
    webvfx.getImage("video").assignToHTMLImageElement(this.image);
    this.context.drawImage(this.image, 0, 0);
}

function init() {
    var filter = new Filter();
    webvfx.renderRequested.connect(filter, Filter.prototype.render);
    webvfx.imageTypeMap = { "video" : webvfx.SourceImageType };
    webvfx.readyRender(true);
}
window.addEventListener("load", init, false);
</script>
</head>
<body>
</body>
</html>
 All Classes Namespaces Functions Variables Enumerations Enumerator