WebRTC too large data size

1,928 views
Skip to first unread message

Tarun Tyagi

unread,
Jun 10, 2015, 11:28:34 AM6/10/15
to discuss...@googlegroups.com
I have been implementing video interview using WebRTC.
Below is my code
--------------------------------------------------------------------------------------------------------------------
var multiStreamRecorder = null;
  var mediaConstraints = {
audio: true,
video: {optional:[ {height:240}, {width:480} ]}
};
navigator.getUserMedia(mediaConstraints, OnSuccess, OnError);
function OnSuccess(stream) {
multiStreamRecorder = new MultiStreamRecorder(stream);
multiStreamRecorder.ondataavailable = function(blobs) {
var fd = new FormData();
fd.append('audio', blobs.audio);
fd.append('video', blobs.video);
 $.ajax({
     url: 'imedia',
     type: 'POST',
     dataType: 'json',
     data: fd,
     processData: false,
     contentType: false
   }); 
console.log(blobs.audio);
console.log(blobs.video);
};
multiStreamRecorder.start(2500);
}
}

It is producing 800KB audio file and 600KB video files after every 5 seconds.

Which means 1.4MB per 5 seconds. This is too much in size to upload on HTTP server.

How we can reduce the size to upload the video/audio files fast?

Thanks
Tarun 

Eric Davies

unread,
Jun 10, 2015, 11:49:42 AM6/10/15
to discuss...@googlegroups.com
If by MultiStreamRecorder, you mean Muaz Khan's MultiStreamRecorder, the answer is "lower your expectations". Muaz's code (when running on Chrome) is basically concatenating a bunch of jpeg stills, without being able to take advantage of the similarity between adjacent images (which is where you get most of your compression in video). It's an wonderfully clever hack, but there is only so far you can take pure javascript. The only way you could lower the size is to reduce the resolution of the images, reduce the frame rate, and/or reduce their quality.

Tarun Tyagi

unread,
Jun 10, 2015, 1:17:38 PM6/10/15
to discuss...@googlegroups.com
Thanks Eric...can you suggest me how to reduce that? 

Eric Davies

unread,
Jun 10, 2015, 2:11:42 PM6/10/15
to discuss...@googlegroups.com
For the framerate and resolution, change the the constraints in your GUM request. I'd check to see what resolution you are actually getting. 480x240 sounds unlikely. 320x240 usually works. 160x120 may work.

For changing the quality of the compression, you'll have to look in MultiStreamRecorder code or ask Muaz (my observation is that he generally answers questions relatively quickly).

--

---
You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/u2N11tBxlOw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/44a11a7e-304b-4807-9fe0-61614200e0bd%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Eric Davies

Santosh Shingare

unread,
Aug 13, 2015, 10:09:19 AM8/13/15
to discuss-webrtc
Dear Eric,

I tried to reduce, but still problem remain same.

video: {
mandatory: {
width: { min: 160 },
height: { min: 120 }
},
optional: [
{ width: { min: 160 }},
{ frameRate: 10 },
{ quality: 10 },

{ facingMode: "user" }
]


How can I reduce size?

Eric Davies

unread,
Aug 13, 2015, 10:39:47 AM8/13/15
to discuss...@googlegroups.com
What camera resolution are you actually seeing?
Check the videoHeight and videoWidth properties of a video object receiving the stream.
You can use chrome:://webrtc-internals to see what the actual frame rate is.



--

---
You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/u2N11tBxlOw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrt...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Randell Jesup

unread,
Aug 14, 2015, 3:16:55 PM8/14/15
to discuss...@googlegroups.com
On 8/13/2015 10:09 AM, Santosh Shingare wrote:

On Wednesday, June 10, 2015 at 8:58:34 PM UTC+5:30, Tarun Tyagi wrote:
I have been implementing video interview using WebRTC.

function OnSuccess(stream) {
multiStreamRecorder = new MultiStreamRecorder(stream);

...


It is producing 800KB audio file and 600KB video files after every 5 seconds.

Which means 1.4MB per 5 seconds. This is too much in size to upload on HTTP server.

How we can reduce the size to upload the video/audio files fast?

You need support in the browser for the bitrate settings on MediaRecorder.  Firefox doesn't have this yet, but we want it.   Changing the input size doesn't change the default bitrate.

-- 
Randell Jesup
randel...@jesup.org

Nikhil Kulkarni

unread,
Sep 3, 2015, 3:19:57 AM9/3/15
to discuss-webrtc
I notice audio size is greater than video size. And Eric offers reasonable explanation for why the video size is so high. What about the audio size ?
Has anyone been able to reduce the audio file size on Chrome ?

Someone mentioned that Mediastream recording API is not yet implemented in Chrome and so the problem. Can we expect it to be fixed soon ? or Moving to another code (other than Muaz's) would solve the problem ? 

On Wednesday, June 10, 2015 at 8:58:34 PM UTC+5:30, Tarun Tyagi wrote:
Reply all
Reply to author
Forward
0 new messages