问题
Is it possible to record 2 webm videos (with WebRTC) and then merge them into one stream (picture in picture).
Example:
recording A shows camera A (streams out)
recording B shows camera B (streams out)
stream A shows one frame with A+B as merged stream (interview between two people)
回答1:
Yes, it is by using the Media Recording API.
First you have to create a <canvas> where you will draw the two <video> elements. When creating the MediaRecorder you will pass the canvas stream: new MediaRecorder(canvas.captureStream()).
In a timeout/interval you will draw the two videos in the canvas: canvas.getContext("2d").drawImage(video, 0, 0, width, height);.
来源:https://stackoverflow.com/questions/40966322/is-it-possible-to-merge-2-webm-video-streams-into-one-stream-in-picture