gpt4 book ai didi

HTML5 : Separate a 1000x1000 video on four different 250x250 videos

转载 作者:搜寻专家 更新时间:2023-10-31 21:49:44 25 4
gpt4 key购买 nike

是否可以使用 HTML5 将一个 1000x1000 的矩形视频分成 4 个不同的 500x500 视频,并以不同方式配置每个较小的矩形?

最佳答案

文章:http://techslides.com/split-video-into-html5-canvas-tiles-with-drag-and-drop/

原始来源:http://techslides.com/demos/split-video-into-canvas-tiles.html

其实很简单:

<div style="display:none">
<video id="source-vid" autoplay loop="true">
<source src="sample-videos/BigBuckBunny_640x360.mp4" type="video/mp4"/>
<source src="sample-videos/BigBuckBunny_640x360.ogv" type="video/ogg"/>
</video>
</div>
<div id="box"></div>
<script src="http://code.jquery.com/jquery-1.7.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript">
ROWS = 3;
COLS = 4;
tiles(640, 360, ROWS, COLS);

var video = $("#source-vid")[0];
update(video);

function update(video) {
tiles(640, 360, ROWS, COLS, video);
setTimeout(function() { update(video) }, 33);
}

function tiles(w, h, r, c, source) {
var tileW = Math.round(w / c);
var tileH = Math.round(h / r);

for(var ri = 0; ri < r; ri += 1) {
for(var ci = 0; ci < c; ci += 1) {
//if source is not specified, just build canvas object, otherwise draw inside them
if (typeof source === 'undefined') {
var tile = $('<canvas class="tile" id="tile' + ri + ci + '" height="' + tileH + '" width="' + tileW + '"></canvas>').get(0);
$("#box").append(tile);
$(".tile").draggable();
} else {
var getit = $('#tile' + ri + ci).get(0);
context = getit.getContext('2d');
context.drawImage(source, ci*tileW, ri*tileH, tileW, tileH, 0, 0, tileW, tileH);
}
}
}

}
</script>

如果您需要没有可拖动脚本的演示,请告诉我。

关于HTML5 : Separate a 1000x1000 video on four different 250x250 videos,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24830508/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com