+150
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
this.getMediaFileWithMaxBitrate = function(streamIndex, maxBitrate) {
var streamItem = this.playlist[streamIndex];
var urls = streamItem.urls;
var resultBitrate = 0;
var highestBitrate = 2000;
var lowestBitrate = 800;
//var resultUrl = urls[0].url;
var resultUrl = "";
//v2.1
// Util.log("##########################getMediaFileWithMaxBitrate ####################");
// Util.log("take the highest of the bitrate range from"
// +lowestBitrate+" to "+highestBitrate+" Mbps else");
for (var i = 0; i < urls.length; i++) {
if(urls[i].type == "video/mp4"){
if (urls[i].bitrate >= lowestBitrate &&
urls[i].bitrate <= highestBitrate && urls[i].bitrate > resultBitrate) {
resultUrl = urls[i].url;
resultBitrate = urls[i].bitrate;
// Util.log(">> " + urls[i].bitrate + " " + urls[i].url);
}
}
}
if (resultUrl == "") {
// Util.log("If there is no MediaFile with type �video/mp4�" +
// "within this range ("+lowestBitrate+"-"+highestBitrate+
// "Mbps) take the next highest MediaFile");
for (var i = 0; i < urls.length; i++) {
if (urls[i].type == "video/mp4") {
if (urls[i].bitrate > highestBitrate &&
(urls[i].bitrate < resultBitrate || resultBitrate == 0)) {
resultUrl = urls[i].url;
resultBitrate = urls[i].bitrate;
// Util.log(">> " + urls[i].bitrate + " " + urls[i].url);
}
}
}
}
if (resultUrl == "") {
// Util.log("If there is no higher MedieFile with type" +
// "�video/mp4� take the next lowest MedieFile");
for (var i = 0; i < urls.length; i++) {
if(urls[i].type == "video/mp4"){
if (urls[i].bitrate < lowestBitrate && urls[i].bitrate > resultBitrate) {
resultUrl = urls[i].url;
resultBitrate = urls[i].bitrate;
//Util.log(">> " + urls[i].bitrate + " " + urls[i].url);
}
}
}
}
if (resultUrl == "" && urls[0].type == "video/mp4") {
resultUrl = urls[0].url;
}
// Util.log(">>>>>>>>>>>>>> AdController.getMediaFileWithMaxBitrate " +
// maxBitrate + " " + resultBitrate + " " + resultUrl);
return resultUrl;
};
Замечательный алгоритм поиска видео более-менее соответствующего критерию "битрейт в диапазоне [а, б], либо первый в (б, *), либо последний в (*, а)".
Запостил: wvxvw,
08 Августа 2013
wvxvw 08.08.2013 18:33 # 0
Это если интересно, во что переделалось.
wvxvw 08.08.2013 21:47 # 0
deep 09.08.2013 05:57 # 0
roman-kashitsyn 09.08.2013 07:08 # +2
bormand 09.08.2013 07:25 # 0
wvxvw 12.08.2013 16:03 # 0
wvxvw 12.08.2013 16:01 # 0