Hi,
I am recording a canvas stream (streamA) which contains video frames exported from a video element and imported into the outputcanvas element using ctx.darimage() within a requestAnimationFrame.
As well as recording the canvas stream, I am adding the audio from the video using the web audio api.
The reason I have to do it this way is that I dynamically pause the video stream for multiple seconds during playback, while still recording.
So I can capture the audio being paused, i have to use:
var source;
var dest;
var getContext = function() {
var ac = null;
if ( !window.AudioContext && !window.webkitAudioContext ) {
console.warn('Web Audio API not supported in this browser');
} else {
ac = new (
window.AudioContext || window.webkitAudioContext )();
}
return function() {
return ac;
};
}();
var audioCtx = getContext();
source = source || audioCtx.createMediaElementSource(video);
dest = dest || audioCtx.createMediaStreamDestination();
source.connect(dest);
var audioTrack = dest.stream.getAudioTracks();
streamA.addTrack(audioTrack[0]);
Which works great and the audio is saved to the output blob fine.
The issue I then have is replaying the source video once the recording is completed.
If I mute the video, it plays fine.
Looking into the issue, it seems that I have disconnected the audiocontext from the video.
I'm wondering if anyone knows how to put it back?
i've tried
source.disconnect(dest);
However this doesn't re-enable audio playback on the source video.