-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from danielbwatson/master
Render two canvas slices from one video
- Loading branch information
Showing
6 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
apply plugin: 'war' | ||
apply plugin: 'jetty' | ||
|
||
jettyRun.contextPath = '/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" type="text/css" href="style/main.css" /> | ||
</head> | ||
<body> | ||
<video controls> | ||
<source src="video/video.webm" type='video/webm; codecs="vp8, vorbis"' /> | ||
</video> | ||
<br/> | ||
<canvas id="primary"></canvas> | ||
<br/> | ||
<canvas id="secondary"></canvas> | ||
<script src="js/jquery.js"></script> | ||
<script src="js/main.js"></script> | ||
</body> | ||
</html> | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
(function() { | ||
var $video, $buffer, $primary, $secondary, video, buffer, primary, secondary, bufferCtx, primaryCtx, secondaryCtx, | ||
initializeCanvases, config; | ||
|
||
// var getResult = $.getJSON('/video/video.json'); | ||
// | ||
// | ||
// console.log(getResult); | ||
// var configText = getResult.responseText; | ||
// console.log(configText); | ||
// config = jQuery.parseJSON(configText); | ||
|
||
|
||
config = { "primary": { "x": 0, "y": 0, "w": 1200, "h": 720 }, "secondary": { "x": 1200, "y": 480, "w": 320, "h": 240 } }; | ||
$video = $('video'); | ||
$primary = $('#primary'); | ||
$secondary = $('#secondary'); | ||
video = $video[0]; | ||
primary = $primary[0]; | ||
secondary = $secondary[0]; | ||
|
||
initializeCanvases = function () { | ||
var renderFrame; | ||
primaryCtx = primary.getContext('2d'); | ||
secondaryCtx = secondary.getContext('2d'); | ||
|
||
primary.height = config.primary.h; | ||
primary.width = config.primary.w; | ||
secondary.width = config.secondary.w; | ||
secondary.height = config.secondary.h; | ||
|
||
renderFrame = function() { | ||
|
||
// Render a slice into the primary canvas. | ||
primaryCtx.drawImage(video, config.primary.x, config.primary.y, config.primary.w, config.primary.h, 0, 0, | ||
config.primary.w, config.primary.h); | ||
|
||
secondaryCtx.drawImage(video, config.secondary.x, config.secondary.y, config.secondary.w, | ||
config.secondary.h, 0, 0, config.secondary.w, config.secondary.h); | ||
}; | ||
setInterval(renderFrame, 30); | ||
|
||
}; | ||
$video.bind('canplay', initializeCanvases); | ||
|
||
video.play(); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
video { display: none; } |
Empty file.