muaz-khan / WebRTC-Experiment

WebRTC, WebRTC and WebRTC. Everything here is all about WebRTC!!
https://www.webrtc-experiment.com/
MIT License
11.71k stars 3.95k forks source link

RecordRTC video and audio combined #52

Open zhuochun opened 11 years ago

zhuochun commented 11 years ago

Hi, muaz

Is there a way to record the video and audio together and output as one file?

Thanks.

muaz-khan commented 11 years ago

RecordRTC's current mechanism is incapable to record both audio and video streams in a single file.

Audio is recorded using Web Audio APIs where onaudioprocess is returning AudioBuffer objects.

Video or GIF is recorded using Canvas2D; where canvas.toDataURL is used to get the DataURL.

Using FileReader API, we can get DataURL from audio buffers too; however it is not easy to merge two unique DataURLs to get appropriate result.

zhuochun commented 11 years ago

I am trying to edit based on your RecordRTC to support video and audio recording together. I want to ask is the setBlob function always needed to get the real blob? It seems to do outputting as a temporary file only.

What I do now is just save the blob:

this.videoBlob = Whammy.fromImageArray(frames, 1000 / 60);

and

recorder.exportWAV(function(blob) {
    this.audioBlob = blob;
 }.bind(this));

The blob files uploaded to server do not have any images or sound in it.

muaz-khan commented 11 years ago

There is a PHP-based solution (i.e. avconv modules) that allows us merge WAV/WebM and output a single MKV. I'll add that solution in this repository: MediaStreamRecorder.js

aojsamurai commented 11 years ago

Please i'll be very grateful, i've been searching for that solution for a while, Muaz-khan thanks

zhuochun commented 11 years ago

Thanks @muaz-khan based on RecordRTC and MediaStreamRecorder, I created mine at record-rtc-together