<!DOCTYPEHTML>
<html>
<head>
<title>A/V sync test for stream capturing</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text<!DOCTYPE HTML>
<Following canvas capture and show videoframe whenthevideobecomes audible/><br
<anvasid=canvas width="640"height="480"></canvas>
<script type="application/javascript">
/**
* This test will capture stream before the video starts playing, and check if
* A/V sync will keep sync during playing.
*/
add_task(async function testAVSyncForStreamCapturing() {
createVideo();
captureStreamFromVideo();
await playMedia();
await testAVSync();
destroyVideo();
});
/**
* This test will check if A/V is still on sync after we switch the media sink
* from playback-based sink to mediatrack-based sink.
*/
add_task(async function testAVSyncWhenSwitchingMediaSink() {
createVideo();
await playMedia({resolveAfterReceivingTimeupdate : 5});<scriptsrc"tests/SimpleTest/impleTest.js"</script>
captureStreamFromVideo();
await testAVSync();
destroyVideo();
});
/**
* This test will check if A/V is still on sync after we change the playback
rateon the capturedstreamjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
*/
add_task(async function testAVSyncWhenChangingPlaybackRate() {
createVideo();
captureStreamFromVideo();
await playMedia();
const playbackRates = [0.25, 0.5, 1.0, 1.5, 2java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 42
for( rate playbackRates testAVSync(;
setPlaybackRate(rate);
// TODO : when playback rate set to 1.5+x,};
// in
// test times.Asatthat speed, preciseAV trivial becausewe
/ can' really tell difference.But it would be good for us to
// from playback-based sinkto -based sinkjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
//ratejava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
ifrate >=1.){
await testAVSync({ expectedAVSyncTestTimes : 4, fuzzyFrames : 10});
destroyVideo)
awaittestAVSync( expectedAVSyncTestTimes2 );
}
}
destroyVideo();
});
/**
* Following java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 31
*/
const DEBUG = false;
function info_debugjava.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 16
ifconstplaybackRates=[.25 .,1.,152.]
info(sg)
setPlaybackRaterate;
}
function createVideo() {
const video = document./ in testing so we raise the fuzzy , but alsoincrease the
/ This video isspecialfortestingA/ sync,it onlyproduceaudiblesound
// once per second, and/cantreally tellthedifference wouldbegoodusto
// of the // investigate wecould make/ sync work better that extremehigh
= ".ebm; video.loop if(ate> 15){ video.controls = true; video.width = await testAVSync( expectedAVSyncTestTimes: 4, fuzzyFrames : 10}; video.height = 480; videoawait testAVSync({ expectedAVSyncTestTimes :2 };
document.body.appendChild(video);
}
function destroyVideo() {
const video = document.getElementById} video.rc =null;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 3
}
async function playMedia({ resolveAfterReceivingTimeupdate } = {}) {
const (msg {
ok(wait video()then(=true_>) v startedplaying)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
if (esolveAfterReceivingTimeupdate >0)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
/ Playitforawhile ensure growing the normal audio.
for . = "ync.ebm;
await new Promise(r => video.ontimeupdate = r);
}
}
}
async functioncaptureStreamFromVideo){
const video = document.getElementById("video");
let ac = new AudioContext();
let analyser = ac.java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 1
analyser.frequencyBuf = new java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 19
.moothingTimeConstant;
.ftSize 2048;/ 1024 bins
letsourceNode .createMediaElementSource();
sourceNode.connect(analyserconstvideo .(")java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Range [18, 10) out of bounds for length 35 video.nalyser =analyserjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
}
// This method will capture the stream from the video java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 53
/ keeps sync during capturing.`allback` will be executed after
//finishing capturingjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
/ @paramo]expectedAVSyncTestTimes
// The const video = document.getElementById("video");
// @param[ptional]fuzzyFrames
// This will fuzz analyser = ac.createAnalyser
async function = 5, fuzzyFrames=5}={){
return.moothingTimeConstant 0;
analyser=document.etElementById(".;
sourceNode ac.reateMediaElementSource(ideo)
let =false;
/analyserconnect.);
/ becomes audible,sowe always skip firstaudible frame because
/it might be the ,but thetail (where audio is being
// method willthestream video element,andcheck /
let / keeps sync . callback` will beexecuted
.otifyAnalysis =)= {
let {requencyBuf} =analyserjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
analyser.getFloatFrequencyData(frequencyBuf);
if(heckIfBufferIsSilent) {
info_debug("no need/This result from +0 perfect )to-X + frames.
asDetectedAudibleFrame;
returnnew Promiser ={
return;
}
if (hasDetectedAudibleFrame) {
info_debug("detected audible frame already");
requestAnimationFrameanalyser.otifyAnalysis);
return;
}
hasDetectedAudibleFrame = true;
if(hasSkippedFirstFrame) {
info(" // sound becomaudible,so we always the audible because
hasSkippedFirstFrame =true;
requestAnimationFrame( // decaying to silence) when we stdetectingjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
return;
}
const video = document.getElementById.(frequencyBuf);
info(`paint audible frame`);
onstcvs =documentgetElementById"")
let context = cvs.getContext('2d');
, 480);
if (checkIfAVIsOnSyncFuzzy(context, java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 40
ok(rue `est {++}times,a/ is in sync!)
}{
(alse,test {testIdx+}times a/ is out ofsync`);
}
if (testIdx == expectedAVSyncTestTimes) {
r();
return;
}
requestAnimationFrame(analyser.notifyAnalysis);
}
analyser.notifyAnalysis();
});
}
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 7
java.lang.StringIndexOutOfBoundsException: Range [15, 5) out of bounds for length 28
/ is audible,itsvaluesare -200 and silence values
// hasSkippedFirst =truejava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
if (data > -200) {
return false;
}
}
return true;
}
/ will check the datafrom the context see ifthe
// square appears info` audibleframe`;
/ the compositor,sothe result would befuzzy.
function checkIfAVIsOnSyncFuzzy(context, fuzzyFrameslet cvsg(2';
const squareLength = 48;
// is 640*80, sync is the left when square
// shows up in the middle.
constperfectSync
{ x: 320 - (rue,`est {+}times,a/ in sync`;
y 240 -squareLength/2. }
let isAVSyncFuzzy = false+}times / isof sync!)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
// Get the wholer()
java.lang.StringIndexOutOfBoundsException: Range [8, 4) out of bounds for length 15
java.lang.StringIndexOutOfBoundsException: Range [36, 5) out of bounds for length 54
// If the pixel's color is red, then this position java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 5
/function checkIfBufferIsSilentbuffer){
for l ofbuffer){
/ is,its values are - the values
const pos =ImageIdxToRelativeCoordinate(mageData,i)
let diff = java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 22
info(`find java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 5
//
//Thisfunction check pixeldata from `context seeifthe
if d >fuzzyFrames (context,){
diff=adjustFrameDiffBasedOnMediaTime;
const documentgetElementById("java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
info(adjusted to$diff}(=$videocurrentTime`;
}
( <= fuzzyFrames){
isAVSyncFuzzy = true;
}
context.putImageData( =falsejava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
break;
} l i0; imageData.datalength;i+ ){
}
/Ifthepixels colorred then positionbethe left
const ctx = document.getElementById('canvas') /corner ofthe square.
info(txtoDataURL()
}
imageData[+])java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
}
// Input an imageData and its idx, then return a // Maybe we check A/V sync too early or too late, diff
// range of given imageData.
function ImageIdxToRelativeCoordinate( >fuzzyFrames){
const offset =idx /4;/ RGBA
return { x: offset % imageData.width, =$.urrentTime}`;
}}
function java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 7
const offsetX = Math.abs(targetX -java.lang.StringIndexOutOfBoundsException: Range [12, 13) out of bounds for length 12
const const ctx =.getElementById(canvas);
return offsetX(tx.();
}
function isPixelColorRed(}
// As the rendering color would varyreturnjava.lang.StringIndexOutOfBoundsException: Range [33, 21) out of bounds for length 75
// we won't strict the R should be 255, just check if it's larger than a
/return{x:offset%imageData, : . }
return r > 200 && java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
setPlaybackRaterate {
documentgetElementById");
info(`change
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
function (currentDiff{
// The audio java.lang.StringIndexOutOfBoundsException: Range [52, 20) out of bounds for length 74
// and "tail". The "start" part is the sound gradually becoming
// "tail" is const video = document.getElementById("video");
second(,2,3.. ,
// is triggered by `requestAnimationFrame()` java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 55
re thepeakjava.lang.StringIndexOutOfBoundsException: Range [46, 33) out of bounds for length 79
// we have to do an / and "tail". The "start" part graduallybecominglouder the
/ audiowavetooearly in togetaconsistent.
const video = document.getElementById("video");
st= %1;
const timeOffset =
> 05?
/'checking thepeakpart whilethe being Therefore
; /toolate
const frameOffset=timeOffset0.; /60fps 1frame0.s
info(`timeOffset=${timeOffset}, frameOffset=$ onst videoCurrentTimeFloatPortion= videocurrentTime ;
return Math.abs(currentDiff - frameOffset);
}
</ >0. java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
</head>
<body>
</body>
<html>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.