admin 管理员组文章数量: 1086019
I recorded video for 10 second in (Firefox/Chrome) using this example /. Recorded blob size around [10 Sec, 4.36MB (320x240)] , Then I modified some parameter as fallows
var videoConstraints = {
audio: false,
video: {
mandatory: {
width: { min: 320 },
height: { min: 240 }
},
optional: [
{ width: 320 },
{ width:
{ min: 320 }
},
{ frameRate: 60 },
{ quality: 10 },
{ width:
{ max: 320 }
},
{ facingMode: "user" }
]
}
};
But still blob size is almost same. what can I do, for reduce recorded blob size.
I recorded video for 10 second in (Firefox/Chrome) using this example https://www.webrtc-experiment./RecordRTC/. Recorded blob size around [10 Sec, 4.36MB (320x240)] , Then I modified some parameter as fallows
var videoConstraints = {
audio: false,
video: {
mandatory: {
width: { min: 320 },
height: { min: 240 }
},
optional: [
{ width: 320 },
{ width:
{ min: 320 }
},
{ frameRate: 60 },
{ quality: 10 },
{ width:
{ max: 320 }
},
{ facingMode: "user" }
]
}
};
But still blob size is almost same. what can I do, for reduce recorded blob size.
Share Improve this question edited Aug 14, 2015 at 11:51 xdumaine 10.3k7 gold badges64 silver badges107 bronze badges asked Aug 14, 2015 at 11:07 Santosh ShingareSantosh Shingare 2813 silver badges16 bronze badges2 Answers
Reset to default 4Your constraints mix Chrome-specific format and the standard, and will work in no browser.
The standard (still requires a polyfill in Chrome):
var constraints = {
video: {
width: { min: 320 },
height: { min: 240 },
advanced: [
{ width: 320 },
{ width: { min: 320 } },
{ frameRate: 60 },
{ width: { max: 320 } },
{ facingMode: "user" }
]
}
};
The standard also lets you express things declaratively, so this is the same/better:
var constraints = {
video: {
width: { min: 320, ideal: 320 },
height: { min: 240 },
frameRate: 60,
facingMode: "user",
}
};
Finally, if you're trying to reduce the size, don't use min
. min
and max
are bounds, so min
wont give you low resolutions, just the opposite, it sets a lower bound. Instead use ideal
for gravity, or even max
.
I wont explain what this would look like in Chrome, since it uses an outdated syntax that wont work in other browsers, but this snippet works across browsers using a polyfill:
var constraints = {
video: {
width: { min: 320, ideal: 320 },
height: { min: 240 },
frameRate: 60,
facingMode: "user",
}
};
function start() {
navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) { v.srcObject = stream; })
.then(function() {
return new Promise(function(r) { v.onloadedmetadata = r;});
})
.then(function() {
log("Success: "+ v.videoWidth +"x"+ v.videoHeight);
})
.catch(failed);
}
function log(msg) { div.innerHTML += "<p>" + msg + "</p>"; }
function failed(e) { log(e + ", line " + e.lineNumber); }
<video id="v" height="120" width="160" autoplay></video><br>
<button onclick="start()">Start!</button><div id="div"></div>
<script src="https://rawgit./webrtc/adapter/master/adapter.js"></script>
quality
is not a standard constraint.
@jib's answer will reduce the resolution/framerate of the capture. However, the reason the blob size doesn't change is that you need to reduce the encoding bitrate for MediaRecorder. However, no browser has implemented bitrate limits for MediaRecorder (Firefox plans to do so soon - Firefox's initial implementation was to support video recording in Firefox OS cameras, and that ran at a fixed bitrate).
本文标签: javascriptWebRTC Reduce a recording video sizeStack Overflow
版权声明:本文标题:javascript - WebRTC Reduce a recording video size - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744088859a2531652.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论