From c71c3d251acd6e3e8b1622a9402bb57d420d4dc5 Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Fri, 24 Sep 2021 07:37:27 +0200 Subject: [PATCH] Prefer 48k audio sample rate --- backend/youtube/helpers.go | 8 ++++---- backend/youtube/helpers_test.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/youtube/helpers.go b/backend/youtube/helpers.go index 9bf21f4..3ec4bf2 100644 --- a/backend/youtube/helpers.go +++ b/backend/youtube/helpers.go @@ -50,12 +50,12 @@ func SortAudio(inFormats youtubev2.FormatList) youtubev2.FormatList { isStereoI := formats[i].AudioChannels == 2 isStereoJ := formats[j].AudioChannels == 2 if isStereoI && isStereoJ { - is44kI := formats[i].AudioSampleRate == "44100" - is44kJ := formats[j].AudioSampleRate == "44100" - if is44kI && is44kJ { + is48kI := formats[i].AudioSampleRate == "48000" + is48kJ := formats[j].AudioSampleRate == "48000" + if is48kI && is48kJ { return formats[i].Bitrate > formats[j].Bitrate } - return is44kI + return is48kI } return isStereoI } diff --git a/backend/youtube/helpers_test.go b/backend/youtube/helpers_test.go index 9547e92..f50233d 100644 --- a/backend/youtube/helpers_test.go +++ b/backend/youtube/helpers_test.go @@ -20,19 +20,19 @@ func TestSortAudio(t *testing.T) { MimeType: `audio/webm; codecs="opus"`, Bitrate: 350_000, AudioChannels: 2, - AudioSampleRate: "44100", + AudioSampleRate: "48000", }, { MimeType: `audio/mp4; codecs="mp4a.40.2"`, Bitrate: 250_000, AudioChannels: 2, - AudioSampleRate: "44100", + AudioSampleRate: "48000", }, { MimeType: `audio/webm; codecs="opus"`, Bitrate: 125_000, AudioChannels: 2, - AudioSampleRate: "44100", + AudioSampleRate: "48000", }, }