| <!doctype html> |
| <html> |
| <head> |
| <title>MediaRecorder video bitrate</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <script> |
| async function record(bitRate) |
| { |
| const stream = await navigator.mediaDevices.getUserMedia({ video : { width : 1024 } }); |
| const recorder = new MediaRecorder(stream, { videoBitsPerSecond : bitRate }); |
| const promise = new Promise((resolve, reject) => { |
| let count = 0; |
| let blobs = []; |
| recorder.ondataavailable = (e) => resolve(e.data); |
| setTimeout(() => reject("datavailable event timed out"), 15000); |
| }); |
| recorder.start(); |
| setTimeout(() => recorder.stop(), 1000); |
| return promise; |
| } |
| |
| promise_test(async (t) => { |
| let blobs = [0, 0]; |
| blobs[0] = await record(50000); |
| blobs[1] = await record(5000000); |
| |
| // We are taking the second blob since it might be more accurate than the first one. |
| assert_greater_than(blobs[0].size, 0, "blob0"); |
| assert_greater_than(blobs[1].size, blobs[0].size, "blob2"); |
| }, "Various video bitrates"); |
| </script> |
| </body> |
| </html> |