0

I am trying to record a video from a canvas with a series of pictures, gif, and also some videos even songs(audio) displaying through time.
Now I have achieved:
- record a video with pictures, gif and videos without any audio using canvas.captureStream() and MediaRecorder
What I want to know:
- Figure out why the recorded video has no audio of the video inside the canvas?
- Is there a way to cancat songs into the recorded video at a specific timestamp?

I notice a similar question (link below) about how to record canvas and audio simultaneously, but I have no idea why the video's audio should deal separately. If it is the only solution, is there any way to add the audio track at a specific time instead of the beginning of the recorded video?

MediaStream Capture Canvas and Audio Simultaneously

Thanks!

soundquiet
  • 485
  • 2
  • 8

1 Answers1

0
  • Figure out why the recorded video has no audio of the video inside the canvas?

Canvases don't have audio.

  • Is there a way to cancat songs into the recorded video at a specific timestamp?

Short of remuxing everything yourself, not really. But, you probably don't need to do this anyway. Simply play back your audio at the same time and record both simultaneously.

Make a new MediaStream that combines the video track from the CanvasCaptureMediaStream, and the audio track from wherever you want it. You can use .getVideoTracks() and .getAudioTracks() on other streams, and instantiate a new stream with an array of tracks.

const stream = new MediaStream([audioTrack, videoTrack]);
Brad
  • 159,648
  • 54
  • 349
  • 530
  • Thank you for the quick response! but I don't understand what is "play back your audio at the same time", can you explain it more clearly? thanks a lot – soundquiet Oct 16 '19 at 03:52
  • @soundquiet Where is your audio coming from? – Brad Oct 16 '19 at 14:00
  • @soundquiet Cool, glad you got it working! If you found this answer helpful, you can check the green checkmark next to it to make it easy for other folks with similar questions in the future to find an answer. – Brad Oct 17 '19 at 02:01