deprioritize kaltura conversions with suspiciously high bitrates
we've seen some broken conversions that are 20x+ larger than the original video. add a quick heuristic to deprioritize any conversion > 5x the size of the original. (seems like if the conversions are substantially larger than the original, then we're doing it wrong.) fixes CNVS-11227 Change-Id: I0b318c609ddd59f4507d38a4b69383f3ff77279c Reviewed-on: https://gerrit.instructure.com/31442 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Product-Review: Bracken Mosbacker <bracken@instructure.com> QA-Review: Nathan Rogowski <nathan@instructure.com>
This commit is contained in:
parent
e784994679
commit
53a6111fb9
|
@ -137,10 +137,19 @@ module Kaltura
|
|||
|
||||
# Given an array of sources, it will sort them putting preferred file types at the front,
|
||||
# preferring converted assets over the original (since they're likely to stream better)
|
||||
# and sorting by descending bitrate for identical file types.
|
||||
# and sorting by descending bitrate for identical file types, discounting
|
||||
# suspiciously high bitrates.
|
||||
def sort_source_list(sources)
|
||||
original_source = sources.detect{ |s| s[:isOriginal].to_i != 0 }
|
||||
# CNVS-11227 features broken conversions at 20x+ the original source's bitrate
|
||||
# (in addition to working conversions at bitrates comparable to the original)
|
||||
suspicious_bitrate_threshold = original_source ? original_source[:bitrate].to_i * 5 : 0
|
||||
sources = sources.sort_by do |a|
|
||||
[a[:hasWarnings] || a[:isOriginal] != '0' ? SortLast : SortFirst, a[:isOriginal] == '0' ? SortFirst : SortLast, PREFERENCE.index(a[:fileExt]) || PREFERENCE.size + 1, 0 - a[:bitrate].to_i]
|
||||
[a[:hasWarnings] || a[:isOriginal] != '0' ? SortLast : SortFirst,
|
||||
a[:isOriginal] == '0' ? SortFirst : SortLast,
|
||||
PREFERENCE.index(a[:fileExt]) || PREFERENCE.size + 1,
|
||||
a[:bitrate].to_i < suspicious_bitrate_threshold ? SortFirst : SortLast,
|
||||
0 - a[:bitrate].to_i]
|
||||
end
|
||||
sources.each{|a| a.delete(:hasWarnings)}
|
||||
sources
|
||||
|
|
|
@ -161,6 +161,22 @@ describe "Kaltura::ClientV3" do
|
|||
{:fileExt => 'mp4', :bitrate => '100', :isOriginal => '0', :hasWarnings => true},
|
||||
]).first[:isOriginal].should_not == '1'
|
||||
end
|
||||
|
||||
it "should sort by descending bitrate but deprioritize sources with suspiciously high bitrates" do
|
||||
@kaltura.sort_source_list(
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '180', :isOriginal => '1'},
|
||||
{:fileExt => 'mp4', :bitrate => '120', :isOriginal => '0'},
|
||||
{:fileExt => 'mp4', :bitrate => '5000', :isOriginal => '0'},
|
||||
{:fileExt => 'mp4', :bitrate => '200', :isOriginal => '0'},
|
||||
]).should ==
|
||||
[
|
||||
{:fileExt => 'mp4', :bitrate => '200', :isOriginal => '0'},
|
||||
{:fileExt => 'mp4', :bitrate => '120', :isOriginal => '0'},
|
||||
{:fileExt => 'mp4', :bitrate => '5000', :isOriginal => '0'},
|
||||
{:fileExt => 'mp4', :bitrate => '180', :isOriginal => '1'},
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
describe 'media_sources' do
|
||||
|
|
Loading…
Reference in New Issue