flash FMS的一些最优参数设置
对任何使用影音串流的 FlashCom 程式来说,影音串流的品质是极重要的,但调校相关参数却需要非常好的技巧及多次测试,无意间逛到国外有人已写好一个计算建议值的小程式,应该对参数的决定有很大帮助。
参数的设定可能因以下因素而不同 ( 并非只看这些因素 ):
使用者连线至主机的频宽,是使用 ADSL、一般的区域网路还是无线网路?
有多少人广播串流?愈多人广播串流,影音品质应调得愈低,以控制总流量。
在相同的频宽下,我们可以提供较低品质但关键影格多的影像 ( fast images ) 或较高品质但关键影格少的影像 ( slow images ),或提供精细品质但更少关键影格的影像 ( high quality )。如果每个使用者都是透过区域网路来连接 FlashCom 主机,那我们就可提供精细品质且关键影格又多的影像 ( high bandwidth )。
影像长宽比,1 / 1 ( portrait )、6 / 5 ( normal )、9 / 5 ( landscape )。
要调整参数我们必需在 client 端的 ActionScript 中使用下列方法:
Camera.setQuality
Camera.setKeyframeInterval
Camera.setMode
Microphone.setRate
具体算法:
m_pb.addEventListener("click", _root);
_root.click = function() {
var bwLabel = m_bw.value;
var numUsers = m_numUsers.value;
var ratio = m_ratio.value;
var speed = m_speed.value;
trace(bwLabel+", "+numUsers+", "+ratio+", "+speed);
//Mic rate
var theRate = 0;
var bwDown = 0;
var bwUp = 0;
switch (bwLabel) {
case "modem":
theRate = 5;
bwDown = 40;
bwUp = 28;
break;
case "dsl":
theRate = 11;
bwDown = 300;
bwUp = 100;
break;
case "lan":
theRate = (numUsers < 2) ? 22 : 11;
bwDown = 600;
bwUp = 300;
break;
}
m_setRate_txt.text = "mic.setRate("+theRate+");";
//Video values
var FPSsum;
var FPSlim;
switch (bwLabel) {
case "modem":
FPSsum = 3;
FPSlim = 2;
break;
case "dsl":
FPSsum = 24;
FPSlim = 12;
break;
case "lan":
FPSsum = 50;
FPSlim = 15;
break;
}
// BWsum is = 2/3 * down
var BWsum = (2/3) * bwDown;
// BWlim is = up/2
// except LAN which is 150
var BWlim = bwUp;
if (bwLabel == "lan")
BWlim = bwUp/2;
// bw is = min(BWlim, BWsum/numUsers);
var bw = Math.min(BWlim, BWsum/numUsers)*1024/8;
var w;
var h;
switch (ratio) {
default:
case "portrait":
w = 120;
h = 120;
break;
case "normal":
w = 140;
h = 104;
break;
case "landscape":
w = 160;
h = 88;
break;
}
// fps is = min(FPSlim, FPSsum/numUsers);
var fps = Math.min(FPSlim, FPSsum/numUsers);
// keyFrameInteval is = max(2*fps, 4)
var kfInt = Math.max(2*fps,4);
//if (broadband and lan) set to 300 (total up)
if ((speed == "high bandwidth")&&(bwLabel == "lan"))
bw = bwUp*1024/8;
m_setQuality_txt.text = "cam.setQuality("+Math.round(bw)+", 0);";
m_setKeyframeInterval_txt.text = "cam.setKeyframeInterval("+kfInt+");";
switch (speed) {
case "slow images":
m_setMode_txt.text = "cam.setMode("+w+", "+h+", "+Math.min(1,fps)+");";
break;
case "fast images":
m_setMode_txt.text = "cam.setMode("+w+", "+h+", "+fps+");";
break;
case "high quality":
// w = 2*w
// h = 2*h
// fps = fps/2
m_setMode_txt.text = "cam.setMode("+w*2+", "+h*2+", "+fps/2+");";
break;
case "high bandwidth":
m_setMode_txt.text = "cam.setMode("+w*2+", "+h*2+", "+((bwLabel == "lan") ? fps : fps/2)+");";
break;
}
}
_root.click();
阅读(763) | 评论(0) | 转发(0) |