How to use VideoFrame method in wpt

Best JavaScript code snippet using wpt

videoFrame-construction.any.js

Source:videoFrame-construction.any.js Github

copy

Full Screen

2// META: script=/webcodecs/utils.js3// META: script=/webcodecs/videoFrame-utils.js4test(t => {5 let image = makeImageBitmap(32, 16);6 let frame = new VideoFrame(image, {timestamp: 10});7 assert_equals(frame.timestamp, 10, 'timestamp');8 assert_equals(frame.duration, null, 'duration');9 assert_equals(frame.visibleRect.width, 32, 'visibleRect.width');10 assert_equals(frame.visibleRect.height, 16, 'visibleRect.height');11 assert_equals(frame.displayWidth, 32, 'displayWidth');12 assert_equals(frame.displayHeight, 16, 'displayHeight');13 frame.close();14}, 'Test we can construct a VideoFrame.');15test(t => {16 let image = makeImageBitmap(32, 16);17 let frame = new VideoFrame(image, {timestamp: 10});18 frame.close();19 assert_equals(frame.format, null, 'format')20 assert_equals(frame.timestamp, null, 'timestamp');21 assert_equals(frame.duration, null, 'duration');22 assert_equals(frame.codedWidth, 0, 'codedWidth');23 assert_equals(frame.codedHeight, 0, 'codedHeight');24 assert_equals(frame.visibleRect, null, 'visibleRect');25 assert_equals(frame.displayWidth, 0, 'displayWidth');26 assert_equals(frame.displayHeight, 0, 'displayHeight');27 assert_equals(frame.colorSpace.primaries, null, 'colorSpace.primaries');28 assert_equals(frame.colorSpace.transfer, null, 'colorSpace.transfer');29 assert_equals(frame.colorSpace.matrix, null, 'colorSpace.matrix');30 assert_equals(frame.colorSpace.fullRange, null, 'colorSpace.fullRange');31 assert_throws_dom('InvalidStateError', () => frame.clone());32}, 'Test closed VideoFrame.');33test(t => {34 let image = makeImageBitmap(32, 16);35 let frame = new VideoFrame(image, {timestamp: -10});36 assert_equals(frame.timestamp, -10, 'timestamp');37 frame.close();38}, 'Test we can construct a VideoFrame with a negative timestamp.');39test(t => {40 let image = makeImageBitmap(1, 1);41 let frame = new VideoFrame(image, {timestamp: 10});42 assert_equals(frame.visibleRect.width, 1, 'visibleRect.width');43 assert_equals(frame.visibleRect.height, 1, 'visibleRect.height');44 assert_equals(frame.displayWidth, 1, 'displayWidth');45 assert_equals(frame.displayHeight, 1, 'displayHeight');46 frame.close();47}, 'Test we can construct an odd-sized VideoFrame.');48test(t => {49 // Test only valid for Window contexts.50 if (!('document' in self))51 return;52 let video = document.createElement('video');53 assert_throws_dom('InvalidStateError', () => {54 let frame = new VideoFrame(video, {timestamp: 10});55 })56}, 'Test constructing w/ unusable image argument throws: HAVE_NOTHING <video>.');57test(t => {58 let canvas = new OffscreenCanvas(0, 0);59 assert_throws_dom('InvalidStateError', () => {60 let frame = new VideoFrame(canvas, {timestamp: 10});61 })62}, 'Test constructing w/ unusable image argument throws: emtpy Canvas.');63test(t => {64 let image = makeImageBitmap(32, 16);65 image.close();66 assert_throws_dom('InvalidStateError', () => {67 let frame = new VideoFrame(image, {timestamp: 10});68 })69}, 'Test constructing w/ unusable image argument throws: closed ImageBitmap.');70test(t => {71 let image = makeImageBitmap(32, 16);72 let frame = new VideoFrame(image, {timestamp: 10});73 frame.close();74 assert_throws_dom('InvalidStateError', () => {75 let newFrame = new VideoFrame(frame);76 })77}, 'Test constructing w/ unusable image argument throws: closed VideoFrame.');78test(t => {79 let init = {80 format: 'I420',81 timestamp: 1234,82 codedWidth: 4,83 codedHeight: 284 };85 let data = new Uint8Array([86 1, 2, 3, 4, 5, 6, 7, 8, // y87 1, 2, // u88 1, 2, // v89 ]);90 let i420Frame = new VideoFrame(data, init);91 let image = makeImageBitmap(32, 16);92 assert_throws_js(93 TypeError,94 () => new VideoFrame(image, {timestamp: 10, visibleRect: {x: -1, y: 0, width: 10, height: 10}}),95 'negative visibleRect x');96 assert_throws_js(97 TypeError,98 () => new VideoFrame(image, {timestamp: 10, visibleRect: {x: 0, y: 0, width: -10, height: 10}}),99 'negative visibleRect width');100 assert_throws_js(101 TypeError,102 () => new VideoFrame(image, {timestamp: 10, visibleRect: {x: 0, y: 0, width: 10, height: 0}}),103 'zero visibleRect height');104 assert_throws_js(105 TypeError,106 () => new VideoFrame(image, {timestamp: 10, visibleRect: {x: 0, y: Infinity, width: 10, height: 10}}),107 'non finite visibleRect y');108 assert_throws_js(109 TypeError,110 () => new VideoFrame(image, {timestamp: 10, visibleRect: {x: 0, y: 0, width: 10, height: Infinity}}),111 'non finite visibleRect height');112 assert_throws_js(113 TypeError,114 () => new VideoFrame(image, {timestamp: 10, visibleRect: {x: 0, y: 0, width: 33, height: 17}}),115 'visibleRect area exceeds coded size');116 assert_throws_js(117 TypeError,118 () => new VideoFrame(image, {timestamp: 10, visibleRect: {x: 2, y: 2, width: 32, height: 16}}),119 'visibleRect outside coded size');120 assert_throws_js(121 TypeError,122 () => new VideoFrame(image, {timestamp: 10, displayHeight: 10}),123 'displayHeight provided without displayWidth');124 assert_throws_js(125 TypeError,126 () => new VideoFrame(image, {timestamp: 10, displayWidth: 10}),127 'displayWidth provided without displayHeight');128 assert_throws_js(129 TypeError,130 () => new VideoFrame(image, {timestamp: 10, displayWidth: 0, displayHeight: 10}),131 'displayWidth is zero');132 assert_throws_js(133 TypeError,134 () => new VideoFrame(image, {timestamp: 10, displayWidth: 10, displayHeight: 0}),135 'displayHeight is zero');136 assert_throws_js(137 TypeError,138 () => new VideoFrame(i420Frame, {visibleRect: {x: 1, y: 0, width: 2, height: 2}}),139 'visibleRect x is not sample aligned');140 assert_throws_js(141 TypeError,142 () => new VideoFrame(i420Frame, {visibleRect: {x: 0, y: 0, width: 1, height: 2}}),143 'visibleRect width is not sample aligned');144}, 'Test invalid CanvasImageSource constructed VideoFrames');145test(t => {146 let init = {147 format: 'I420',148 timestamp: 1234,149 codedWidth: 4,150 codedHeight: 2151 };152 let data = new Uint8Array([153 1, 2, 3, 4, 5, 6, 7, 8, // y154 1, 2, // u155 1, 2, // v156 ]);157 let origFrame = new VideoFrame(data, init);158 let cropLeftHalf = new VideoFrame(origFrame, {visibleRect : {x: 0, y: 0, width: 2, height: 2}});159 assert_equals(cropLeftHalf.codedWidth, origFrame.codedWidth);160 assert_equals(cropLeftHalf.codedHeight, origFrame.codedHeight);161 assert_equals(cropLeftHalf.visibleRect.x, 0);162 assert_equals(cropLeftHalf.visibleRect.y, 0);163 assert_equals(cropLeftHalf.visibleRect.width, 2);164 assert_equals(cropLeftHalf.visibleRect.height, 2);165 assert_equals(cropLeftHalf.displayWidth, 2);166 assert_equals(cropLeftHalf.displayHeight, 2);167}, 'Test visibleRect metadata override where source display size = visible size');168test(t => {169 let init = {170 format: 'I420',171 timestamp: 1234,172 codedWidth: 4,173 codedHeight: 2,174 displayWidth: 8,175 displayHeight: 2176 };177 let data = new Uint8Array([178 1, 2, 3, 4, 5, 6, 7, 8, // y179 1, 2, // u180 1, 2, // v181 ]);182 let anamorphicFrame = new VideoFrame(data, init);183 let cropRightFrame = new VideoFrame(anamorphicFrame, {visibleRect : {x: 2, y: 0, width: 2, height: 2}});184 assert_equals(cropRightFrame.codedWidth, anamorphicFrame.codedWidth);185 assert_equals(cropRightFrame.codedHeight, anamorphicFrame.codedHeight);186 assert_equals(cropRightFrame.visibleRect.x, 2);187 assert_equals(cropRightFrame.visibleRect.y, 0);188 assert_equals(cropRightFrame.visibleRect.width, 2);189 assert_equals(cropRightFrame.visibleRect.height, 2);190 assert_equals(cropRightFrame.displayWidth, 4, 'cropRightFrame.displayWidth');191 assert_equals(cropRightFrame.displayHeight, 2, 'cropRightFrame.displayHeight');192}, 'Test visibleRect metadata override where source display width = 2 * visible width (anamorphic)');193test(t => {194 let init = {195 format: 'I420',196 timestamp: 1234,197 codedWidth: 4,198 codedHeight: 2,199 displayWidth: 8,200 displayHeight: 4201 };202 let data = new Uint8Array([203 1, 2, 3, 4, 5, 6, 7, 8, // y204 1, 2, // u205 1, 2, // v206 ]);207 let scaledFrame = new VideoFrame(data, init);208 let cropRightFrame = new VideoFrame(scaledFrame, {visibleRect : {x: 2, y: 0, width: 2, height: 2}});209 assert_equals(cropRightFrame.codedWidth, scaledFrame.codedWidth);210 assert_equals(cropRightFrame.codedHeight, scaledFrame.codedHeight);211 assert_equals(cropRightFrame.visibleRect.x, 2);212 assert_equals(cropRightFrame.visibleRect.y, 0);213 assert_equals(cropRightFrame.visibleRect.width, 2);214 assert_equals(cropRightFrame.visibleRect.height, 2);215 assert_equals(cropRightFrame.displayWidth, 4, 'cropRightFrame.displayWidth');216 assert_equals(cropRightFrame.displayHeight, 4, 'cropRightFrame.displayHeight');217}, 'Test visibleRect metadata override where source display size = 2 * visible size for both width and height');218test(t => {219 let image = makeImageBitmap(32, 16);220 let scaledFrame = new VideoFrame(image,221 { visibleRect : {x: 0, y: 0, width: 2, height: 2},222 displayWidth: 10, displayHeight: 20223 });224 assert_equals(scaledFrame.codedWidth, 32);225 assert_equals(scaledFrame.codedHeight, 16);226 assert_equals(scaledFrame.visibleRect.x, 0);227 assert_equals(scaledFrame.visibleRect.y, 0);228 assert_equals(scaledFrame.visibleRect.width, 2);229 assert_equals(scaledFrame.visibleRect.height, 2);230 assert_equals(scaledFrame.displayWidth, 10, 'scaledFrame.displayWidth');231 assert_equals(scaledFrame.displayHeight, 20, 'scaledFrame.displayHeight');232}, 'Test visibleRect + display size metadata override');233test(t => {234 let image = makeImageBitmap(32, 16);235 let scaledFrame = new VideoFrame(image,236 {237 displayWidth: 10, displayHeight: 20238 });239 assert_equals(scaledFrame.codedWidth, 32);240 assert_equals(scaledFrame.codedHeight, 16);241 assert_equals(scaledFrame.visibleRect.x, 0);242 assert_equals(scaledFrame.visibleRect.y, 0);243 assert_equals(scaledFrame.visibleRect.width, 32);244 assert_equals(scaledFrame.visibleRect.height, 16);245 assert_equals(scaledFrame.displayWidth, 10, 'scaledFrame.displayWidth');246 assert_equals(scaledFrame.displayHeight, 20, 'scaledFrame.displayHeight');247}, 'Test display size metadata override');248test(t => {249 assert_throws_js(250 TypeError,251 () => new VideoFrame(252 new Uint8Array(1),253 {format: 'ABCD', timestamp: 1234, codedWidth: 4, codedHeight: 2}),254 'invalid pixel format');255 assert_throws_js(256 TypeError,257 () =>258 new VideoFrame(new Uint32Array(1), {format: 'RGBA', timestamp: 1234}),259 'missing coded size');260 function constructFrame(init) {261 let data = new Uint8Array([262 1, 2, 3, 4, 5, 6, 7, 8, // y263 1, 2, // u264 1, 2, // v265 ]);266 return new VideoFrame(data, {...init, format: 'I420'});267 }268 assert_throws_js(269 TypeError, () => constructFrame({270 timestamp: 1234,271 codedWidth: Math.pow(2, 32) - 1,272 codedHeight: Math.pow(2, 32) - 1,273 }),274 'invalid coded size');275 assert_throws_js(276 TypeError,277 () => constructFrame({timestamp: 1234, codedWidth: 4, codedHeight: 0}),278 'invalid coded height');279 assert_throws_js(280 TypeError,281 () => constructFrame({timestamp: 1234, codedWidth: 0, codedHeight: 4}),282 'invalid coded width');283 assert_throws_js(284 TypeError, () => constructFrame({285 timestamp: 1234,286 codedWidth: 4,287 codedHeight: 2,288 visibleRect: {x: 100, y: 100, width: 1, height: 1}289 }),290 'invalid visible left/right');291 assert_throws_js(292 TypeError, () => constructFrame({293 timestamp: 1234,294 codedWidth: 4,295 codedHeight: 2,296 visibleRect: {x: 0, y: 0, width: 0, height: 2}297 }),298 'invalid visible width');299 assert_throws_js(300 TypeError, () => constructFrame({301 timestamp: 1234,302 codedWidth: 4,303 codedHeight: 2,304 visibleRect: {x: 0, y: 0, width: 2, height: 0}305 }),306 'invalid visible height');307 assert_throws_js(308 TypeError, () => constructFrame({309 timestamp: 1234,310 codedWidth: 4,311 codedHeight: 2,312 visibleRect: {x: 0, y: 0, width: -100, height: -100}313 }),314 'invalid negative visible size');315 assert_throws_js(316 TypeError, () => constructFrame({317 timestamp: 1234,318 codedWidth: 4,319 codedHeight: 2,320 displayWidth: Math.pow(2, 32),321 }),322 'invalid display width');323 assert_throws_js(324 TypeError, () => constructFrame({325 timestamp: 1234,326 codedWidth: 4,327 codedHeight: 2,328 displayWidth: Math.pow(2, 32) - 1,329 displayHeight: Math.pow(2, 32)330 }),331 'invalid display height');332}, 'Test invalid buffer constructed VideoFrames');333test(t => {334 testBufferConstructedI420Frame('Uint8Array(ArrayBuffer)');335}, 'Test Uint8Array(ArrayBuffer) constructed I420 VideoFrame');336test(t => {337 testBufferConstructedI420Frame('ArrayBuffer');338}, 'Test ArrayBuffer constructed I420 VideoFrame');339test(t => {340 let fmt = 'I420';341 let vfInit = {342 format: fmt,343 timestamp: 1234,344 codedWidth: 4,345 codedHeight: 2,346 colorSpace: {347 primaries: 'smpte170m',348 matrix: 'bt470bg',349 },350 };351 let data = new Uint8Array([352 1, 2, 3, 4, 5, 6, 7, 8, // y353 1, 2, // u354 1, 2, // v355 ]);356 let frame = new VideoFrame(data, vfInit);357 assert_equals(frame.colorSpace.primaries, 'smpte170m', 'color primaries');358 assert_true(frame.colorSpace.transfer == null, 'color transfer');359 assert_equals(frame.colorSpace.matrix, 'bt470bg', 'color matrix');360 assert_true(frame.colorSpace.fullRange == null, 'color range');361}, 'Test planar constructed I420 VideoFrame with colorSpace');362test(t => {363 let fmt = 'I420A';364 let vfInit = {format: fmt, timestamp: 1234, codedWidth: 4, codedHeight: 2};365 let data = new Uint8Array([366 1, 2, 3, 4, 5, 6, 7, 8, // y367 1, 2, // u368 1, 2, // v369 8, 7, 6, 5, 4, 3, 2, 1, // a370 ]);371 let frame = new VideoFrame(data, vfInit);372 assert_equals(frame.format, fmt, 'plane format');373 assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries');374 assert_equals(frame.colorSpace.transfer, 'bt709', 'color transfer');375 assert_equals(frame.colorSpace.matrix, 'bt709', 'color matrix');376 assert_false(frame.colorSpace.fullRange, 'color range');377 frame.close();378 // Most constraints are tested as part of I420 above.379 let y = {offset: 0, stride: 4};380 let u = {offset: 8, stride: 2};381 let v = {offset: 10, stride: 2};382 let a = {offset: 12, stride: 4};383 assert_throws_js(TypeError, () => {384 let a = {offset: 12, stride: 1};385 let frame = new VideoFrame(data, {...vfInit, layout: [y, u, v, a]});386 }, 'a stride too small');387 assert_throws_js(TypeError, () => {388 let frame = new VideoFrame(data.slice(0, 12), vfInit);389 }, 'data too small');390}, 'Test buffer constructed I420+Alpha VideoFrame');391test(t => {392 let fmt = 'NV12';393 let vfInit = {format: fmt, timestamp: 1234, codedWidth: 4, codedHeight: 2};394 let data = new Uint8Array([395 1, 2, 3, 4, 5, 6, 7, 8, // y396 1, 2, 3, 4, // uv397 ]);398 let frame = new VideoFrame(data, vfInit);399 assert_equals(frame.format, fmt, 'plane format');400 assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries');401 assert_equals(frame.colorSpace.transfer, 'bt709', 'color transfer');402 assert_equals(frame.colorSpace.matrix, 'bt709', 'color matrix');403 assert_false(frame.colorSpace.fullRange, 'color range');404 frame.close();405 let y = {offset: 0, stride: 4};406 let uv = {offset: 8, stride: 4};407 assert_throws_js(TypeError, () => {408 let y = {offset: 0, stride: 1};409 let frame = new VideoFrame(data, {...vfInit, layout: [y, uv]});410 }, 'y stride too small');411 assert_throws_js(TypeError, () => {412 let uv = {offset: 8, stride: 1};413 let frame = new VideoFrame(data, {...vfInit, layout: [y, uv]});414 }, 'uv stride too small');415 assert_throws_js(TypeError, () => {416 let frame = new VideoFrame(data.slice(0, 8), vfInit);417 }, 'data too small');418}, 'Test buffer constructed NV12 VideoFrame');419test(t => {420 let vfInit = {timestamp: 1234, codedWidth: 4, codedHeight: 2};421 let data = new Uint8Array([422 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,423 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,424 ]);425 let frame = new VideoFrame(data, {...vfInit, format: 'RGBA'});426 assert_equals(frame.format, 'RGBA', 'plane format');427 assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries');428 assert_equals(frame.colorSpace.transfer, 'iec61966-2-1', 'color transfer');429 assert_equals(frame.colorSpace.matrix, 'rgb', 'color matrix');430 assert_true(frame.colorSpace.fullRange, 'color range');431 frame.close();432 frame = new VideoFrame(data, {...vfInit, format: 'RGBX'});433 assert_equals(frame.format, 'RGBX', 'plane format');434 assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries');435 assert_equals(frame.colorSpace.transfer, 'iec61966-2-1', 'color transfer');436 assert_equals(frame.colorSpace.matrix, 'rgb', 'color matrix');437 assert_true(frame.colorSpace.fullRange, 'color range');438 frame.close();439 frame = new VideoFrame(data, {...vfInit, format: 'BGRA'});440 assert_equals(frame.format, 'BGRA', 'plane format');441 assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries');442 assert_equals(frame.colorSpace.transfer, 'iec61966-2-1', 'color transfer');443 assert_equals(frame.colorSpace.matrix, 'rgb', 'color matrix');444 assert_true(frame.colorSpace.fullRange, 'color range');445 frame.close();446 frame = new VideoFrame(data, {...vfInit, format: 'BGRX'});447 assert_equals(frame.format, 'BGRX', 'plane format');448 assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries');449 assert_equals(frame.colorSpace.transfer, 'iec61966-2-1', 'color transfer');450 assert_equals(frame.colorSpace.matrix, 'rgb', 'color matrix');451 assert_true(frame.colorSpace.fullRange, 'color range');452 frame.close();453}, 'Test buffer constructed RGB VideoFrames');454test(t => {455 let image = makeImageBitmap(32, 16);456 let frame = new VideoFrame(image, {timestamp: 0});457 assert_true(!!frame);458 frame_copy = new VideoFrame(frame);459 assert_equals(frame.format, frame_copy.format);460 assert_equals(frame.timestamp, frame_copy.timestamp);461 assert_equals(frame.codedWidth, frame_copy.codedWidth);462 assert_equals(frame.codedHeight, frame_copy.codedHeight);463 assert_equals(frame.displayWidth, frame_copy.displayWidth);464 assert_equals(frame.displayHeight, frame_copy.displayHeight);465 assert_equals(frame.duration, frame_copy.duration);466 frame_copy.close();467 frame_copy = new VideoFrame(frame, {duration: 1234});468 assert_equals(frame.timestamp, frame_copy.timestamp);469 assert_equals(frame_copy.duration, 1234);470 frame_copy.close();471 frame_copy = new VideoFrame(frame, {timestamp: 1234, duration: 456});472 assert_equals(frame_copy.timestamp, 1234);473 assert_equals(frame_copy.duration, 456);474 frame_copy.close();475 frame.close();476}, 'Test VideoFrame constructed VideoFrame');477test(t => {478 let canvas = makeOffscreenCanvas(16, 16);479 let frame = new VideoFrame(canvas);480 assert_equals(frame.displayWidth, 16);481 assert_equals(frame.displayHeight, 16);482 frame.close();483}, 'Test we can construct a VideoFrame from an offscreen canvas.');484test(t => {485 let fmt = 'I420A';486 let vfInit = {format: fmt, timestamp: 1234, codedWidth: 4, codedHeight: 2};487 let data = new Uint8Array([488 1, 2, 3, 4, 5, 6, 7, 8, // y489 1, 2, // u490 1, 2, // v491 8, 7, 6, 5, 4, 3, 2, 1, // a492 ]);493 let frame = new VideoFrame(data, vfInit);494 assert_equals(frame.format, fmt, 'plane format');495 let alpha_frame_copy = new VideoFrame(frame, {alpha: 'keep'});496 assert_equals(alpha_frame_copy.format, 'I420A', 'plane format');497 let opaque_frame_copy = new VideoFrame(frame, {alpha: 'discard'});498 assert_equals(opaque_frame_copy.format, 'I420', 'plane format');499 frame.close();500 alpha_frame_copy.close();501 opaque_frame_copy.close();502}, 'Test I420A VideoFrame and alpha={keep,discard}');503test(t => {504 let vfInit = {timestamp: 1234, codedWidth: 4, codedHeight: 2};505 let data = new Uint8Array([506 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,507 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,508 ]);509 let frame = new VideoFrame(data, {...vfInit, format: 'RGBA'});510 assert_equals(frame.format, 'RGBA', 'plane format');511 let alpha_frame_copy = new VideoFrame(frame, {alpha: 'keep'});512 assert_equals(alpha_frame_copy.format, 'RGBA', 'plane format');513 let opaque_frame_copy = new VideoFrame(frame, {alpha: 'discard'});514 assert_equals(opaque_frame_copy.format, 'RGBX', 'plane format');515 alpha_frame_copy.close();516 opaque_frame_copy.close();517 frame.close();518 frame = new VideoFrame(data, {...vfInit, format: 'BGRA'});519 assert_equals(frame.format, 'BGRA', 'plane format');520 alpha_frame_copy = new VideoFrame(frame, {alpha: 'keep'});521 assert_equals(alpha_frame_copy.format, 'BGRA', 'plane format');522 opaque_frame_copy = new VideoFrame(frame, {alpha: 'discard'});523 assert_equals(opaque_frame_copy.format, 'BGRX', 'plane format');524 alpha_frame_copy.close();525 opaque_frame_copy.close();526 frame.close();527}, 'Test RGBA, BGRA VideoFrames with alpha={keep,discard}');528test(t => {529 let canvas = makeOffscreenCanvas(16, 16, {alpha: true});530 let frame = new VideoFrame(canvas);531 assert_true(532 frame.format == 'RGBA' || frame.format == 'BGRA' ||533 frame.format == 'I420A',534 'plane format should have alpha: ' + frame.format);535 frame.close();536 frame = new VideoFrame(canvas, {alpha: 'discard'});537 assert_true(538 frame.format == 'RGBX' || frame.format == 'BGRX' ||539 frame.format == 'I420',540 'plane format should not have alpha: ' + frame.format);541 frame.close();...

Full Screen

Full Screen

framerate.js

Source:framerate.js Github

copy

Full Screen

...21HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR22OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.23*/24var VideoFrame = function(a) {25 if (this === window) return new VideoFrame(a);26 this.obj = a || {};27 this.frameRate = this.obj.frameRate || 24;28 this.video = document.getElementById(this.obj.id) || document.getElementsByTagName("video")[0]29 },30 FrameRates = {31 film: 24,32 NTSC: 29.97,33 NTSC_Film: 23.98,34 NTSC_HD: 59.94,35 PAL: 25,36 PAL_HD: 50,37 web: 30,38 high: 6039 };...

Full Screen

Full Screen

fullScreenController.js

Source:fullScreenController.js Github

copy

Full Screen

1var fullScreenController = (function () {2 var changeFullscreen = function (videoPlayer) {3 if (browser.name !== "IE") {4 if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement){5 if (videoPlayer.videoframe.requestFullscreen) {6 videoPlayer.videoframe.requestFullscreen();7 } else if (videoPlayer.videoframe.mozRequestFullScreen) {8 videoPlayer.videoframe.mozRequestFullScreen();9 } else if (videoPlayer.videoframe.webkitRequestFullscreen) {10 videoPlayer.videoframe.webkitRequestFullscreen();11 }12 } else {13 if (document.exitFullscreen) {14 document.exitFullscreen();15 } else if (document.mozCancelFullScreen) {16 document.mozCancelFullScreen();17 } else if (document.webkitExitFullscreen) {18 document.webkitExitFullscreen();19 }20 }21 } else {22 if (!videoPlayer.state.isFull) {23 videoPlayer.videoframe.msRequestFullscreen();24 } else {25 document.msExitFullscreen();26 }27 }28 };29 30 return { 31 changeFullscreen: changeFullscreen32 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.page('Barack Obama').then(function(page) {3 return page.getVideoFrame();4}).then(function(image) {5 console.log(image);6});7var wptools = require('wptools');8wptools.page('Barack Obama').then(function(page) {9 return page.getVideoInfo();10}).then(function(image) {11 console.log(image);12});13var wptools = require('wptools');14wptools.page('Barack Obama').then(function(page) {15 return page.getVideo();16}).then(function(image) {17 console.log(image);18});19var wptools = require('wptools');20wptools.page('Barack Obama').then(function(page) {21 return page.getWikidata();22}).then(function(image) {23 console.log(image);24});25var wptools = require('wptools');26wptools.page('Barack Obama').then(function(page) {27 return page.getWikidataLabels();28}).then(function(image) {29 console.log(image);30});31var wptools = require('wptools');32wptools.page('Barack Obama').then(function(page) {33 return page.getWikidataSitelinks();34}).then(function(image) {35 console.log(image);36});37var wptools = require('wptools');38wptools.page('Barack Obama').then(function(page) {39 return page.getWikidataClaims();40}).then(function(image) {41 console.log(image);42});43var wptools = require('wptools');44wptools.page('Barack Obama').then(function(page) {45 return page.getWikidataClaims();46}).then(function(image) {47 console.log(image);48});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3wptools.videoFrame({4}, function(err, res) {5 if (err) {6 console.log(err);7 } else {8 console.log(res);9 }10});11var wptools = require('wptools');12var fs = require('fs');13wptools.videoFrame({14 output: fs.createWriteStream('AlbertEinstein.jpg'),15}, function(err, res) {16 if (err) {17 console.log(err);18 } else {19 console.log(res);20 }21});22var wptools = require('wptools');23var fs = require('fs');24wptools.videoFrame({25 output: fs.createWriteStream('AlbertEinstein.jpg'),26 callback: function(err, res) {27 if (err) {28 console.log(err);29 } else {30 console.log(res);31 }32 }33});34var wptools = require('wptools');35var fs = require('fs');36wptools.videoFrame({37 output: fs.createWriteStream('AlbertEinstein.jpg'),38 callback: function(err, res) {39 if (err) {40 console.log(err);41 } else {42 console.log(res);43 }44 }45}, function(err, res) {46 if (err) {47 console.log(err

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2var wpt = new WebPageTest('www.webpagetest.org');3var location = 'Dulles:Chrome';4wpt.runTest(url, location, function(err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data);9 }10});11var wpt = require('wpt');12var wpt = require('./wpt');13var wpt = require('./wpt.js');14var wpt = require('wpt.js');15var wpt = require('wpt.js');16var wpt = require('wpt');17var wpt = require('./wpt.js');18var wpt = require('./wpt');19var wpt = require('./wpt.js');20var wpt = require('wpt');21var wpt = require('./wpt');22var wpt = require('./wpt.js');23var wpt = require('wpt.js');24var wpt = require('wpt');25var wpt = require('./wpt.js');26var wpt = require('./wpt');27var wpt = require('./wpt.js');28var wpt = require('wpt.js');29var wpt = require('wpt');30var wpt = require('./wpt.js');31var wpt = require('./wpt');32var wpt = require('./wpt.js');33var wpt = require('wpt.js');34var wpt = require('wpt');35var wpt = require('./wpt.js');36var wpt = require('./wpt');37var wpt = require('./wpt.js');38var wpt = require('wpt.js');39var wpt = require('wpt');40var wpt = require('./wpt.js');41var wpt = require('./wpt');42var wpt = require('./wpt.js');43var wpt = require('wpt.js');44var wpt = require('wpt');45var wpt = require('./wpt.js');46var wpt = require('./wpt');47var wpt = require('./wpt.js');48var wpt = require('wpt.js');49var wpt = require('wpt');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = new wptools.page('Barack Obama', {format: 'json'});3wp.get(function(err, info, next, image){4 if(err){5 console.log(err);6 }else{7 console.log(info);8 }9});10var wptools = require('wptools');11var wp = new wptools.page('Barack Obama', {format: 'json'});12wp.get(function(err, info, next, image){13 if(err){14 console.log(err);15 }else{16 console.log(info);17 }18});19var wptools = require('wptools');20var wp = new wptools.page('Barack Obama', {format: 'json'});21wp.get(function(err, info, next, image){22 if(err){23 console.log(err);24 }else{25 console.log(info);26 }27});28var wptools = require('wptools');29var wp = new wptools.page('Barack Obama', {format: 'json'});30wp.get(function(err, info, next, image){31 if(err){32 console.log(err);33 }else{34 console.log(info);35 }36});37var wptools = require('wptools');38var wp = new wptools.page('Barack Obama', {format: 'json'});39wp.get(function(err, info, next, image){40 if(err){41 console.log(err);42 }else{43 console.log(info);44 }45});46var wptools = require('wptools');47var wp = new wptools.page('Barack Obama', {format: 'json'});48wp.get(function(err, info, next, image){49 if(err){50 console.log(err);51 }else{52 console.log(info);53 }54});55var wptools = require('wptools');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = wptools.page('Barack Obama');3wiki.get(function(err, data) {4 console.log(data);5 var images = data.images;6 var frames = [];7 for (var i = 0; i < images.length; i++) {8 frames.push(wiki.videoFrame(images[i], 10));9 }10 console.log(frames);11});12{13 "scripts": {14 },15 "dependencies": {16 }17}18var wptools = require('wptools');19var wiki = wptools.page('Barack Obama');20wiki.get(function(err, data) {21 console.log(data);22 var images = data.images;23 var frames = [];24 for (var i = 0; i < images.length; i++) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.setOptions({3});4var options = {5};6wptools.page('Barack Obama').then(function (page) {7 return page.videoFrame(options);8}).then(function (result) {9 console.log(result);10});11var wptools = require('wptools');12wptools.setOptions({13});14var options = {15};16wptools.page('Barack Obama').then(function (page) {17 return page.videoFrame(options).then(function (result) {18 console.log(result);19 });20});21var wptools = require('wptools');22wptools.setOptions({23});24var options = {25};26wptools.page('Barack Obama').then(function (page) {27 return page.videoFrame(options).then(function (result) {28 console.log(result);29 });30});31var wptools = require('wptools');32wptools.setOptions({

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var videoFrame = wptools.videoFrame;3videoFrame(url, function(err, data) {4 if (err) {5 console.log('error', err);6 } else {7 console.log('data', data);8 }9});10var wptools = require('wptools');11var videoFrame = wptools.videoFrame;12videoFrame(url, function(err, data) {13 if (err) {14 console.log('error', err);15 } else {16 console.log('data', data);17 }18});19var wptools = require('wptools');20var videoFrame = wptools.videoFrame;21videoFrame(url, function(err, data) {22 if (err) {23 console.log('error', err);24 } else {25 console.log('data', data);26 }27});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful