- From: guest271314 via GitHub <sysbot+gh@w3.org>
- Date: Sat, 12 Sep 2020 14:43:42 +0000
- To: public-webrtc-logs@w3.org
Note also, relevant to dynamic input of _variable_ `width` and `height` frames that are intended to be displayed at an `HTMLVideoElement` and, or streamed to a different peer using `RTCPeerConnection` it might be necessary to await `resize` event of `<video>` element before transmitting or recording the frame to avoid displaying a frame in between the previous frame dimensions and expected frame dimensions - resizing of the frame is not instantaneous and `MediaStreamTrack` does not have a `resize` event, and `unmute` event needs to be checked - particularly at Chromium and particularly when replacing a track in mid-stream
```
for (const blobURL of urls) {
await new Promise(resolve => {
videoStream.addEventListener("pause", async _ => {
recorder.pause();
resolve();
}, {
once: true
});
videoStream.addEventListener("canplay", async _ => {
if (!recorder) {
await new Promise(resizedPromise => {
const handleResize = async _ => {
const {
width, height
} = ms.getVideoTracks()[0].getSettings();
console.log(video.width, width);
if (video.width === width && video.height === height) {
console.log(video.width, width);
video.removeEventListener("resize", handleResize);
await new Promise(unmutePromise => {
const [track] = mediaStream.getVideoTracks();
let now = performance.now();
console.log(video.currentTime, track.muted, stream.getVideoTracks()[0].muted, ms.getVideoTracks()[0].muted);
track.addEventListener("unmute", async _ => {
console.log(_.type, (performance.now() - now) / 1000, video.currentTime, video.width, video.videoWidth, track.getSettings().width);
unmutePromise(await videoStream.play());
}, {
once: true
})
});
recorder = new MediaRecorder(stream, {
mimeType: "video/x-matroska;codecs=h264"
});
recorder.onstart = _ => {
console.log(_.type);
}
result = new Promise(resolve => {
recorder.addEventListener("dataavailable", ({
data
}) => {
resolve(data);
}, {
once: true
})
});
recorder.start();
resizedPromise();
}
}
video.addEventListener("resize", handleResize);
});
} else {
await videoStream.play();
recorder.resume();
}
}, {
once: true
});
videoStream.src = blobURL;
});
}
```
see https://plnkr.co/edit/Axkb8s?preview.
--
GitHub Notification of comment by guest271314
Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/723#issuecomment-691500435 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Saturday, 12 September 2020 14:43:44 UTC