Prefer 48k audio sample rate
This commit is contained in:
parent
cc74da0871
commit
c71c3d251a
|
@ -50,12 +50,12 @@ func SortAudio(inFormats youtubev2.FormatList) youtubev2.FormatList {
|
||||||
isStereoI := formats[i].AudioChannels == 2
|
isStereoI := formats[i].AudioChannels == 2
|
||||||
isStereoJ := formats[j].AudioChannels == 2
|
isStereoJ := formats[j].AudioChannels == 2
|
||||||
if isStereoI && isStereoJ {
|
if isStereoI && isStereoJ {
|
||||||
is44kI := formats[i].AudioSampleRate == "44100"
|
is48kI := formats[i].AudioSampleRate == "48000"
|
||||||
is44kJ := formats[j].AudioSampleRate == "44100"
|
is48kJ := formats[j].AudioSampleRate == "48000"
|
||||||
if is44kI && is44kJ {
|
if is48kI && is48kJ {
|
||||||
return formats[i].Bitrate > formats[j].Bitrate
|
return formats[i].Bitrate > formats[j].Bitrate
|
||||||
}
|
}
|
||||||
return is44kI
|
return is48kI
|
||||||
}
|
}
|
||||||
return isStereoI
|
return isStereoI
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,19 @@ func TestSortAudio(t *testing.T) {
|
||||||
MimeType: `audio/webm; codecs="opus"`,
|
MimeType: `audio/webm; codecs="opus"`,
|
||||||
Bitrate: 350_000,
|
Bitrate: 350_000,
|
||||||
AudioChannels: 2,
|
AudioChannels: 2,
|
||||||
AudioSampleRate: "44100",
|
AudioSampleRate: "48000",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MimeType: `audio/mp4; codecs="mp4a.40.2"`,
|
MimeType: `audio/mp4; codecs="mp4a.40.2"`,
|
||||||
Bitrate: 250_000,
|
Bitrate: 250_000,
|
||||||
AudioChannels: 2,
|
AudioChannels: 2,
|
||||||
AudioSampleRate: "44100",
|
AudioSampleRate: "48000",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MimeType: `audio/webm; codecs="opus"`,
|
MimeType: `audio/webm; codecs="opus"`,
|
||||||
Bitrate: 125_000,
|
Bitrate: 125_000,
|
||||||
AudioChannels: 2,
|
AudioChannels: 2,
|
||||||
AudioSampleRate: "44100",
|
AudioSampleRate: "48000",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue