From 82b1eeac7656c9b507989e6e30a053919e69916f Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 23 Jul 2022 20:01:22 +0200 Subject: [PATCH] renge/invidious: Rebase patch This is a re-implementation since upstream added a similar functionality but prefers aac over opus. --- ...er-opus-audio-streams-in-listen-mode.patch | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/machines/renge/services/invidious/0001-Prefer-opus-audio-streams-in-listen-mode.patch b/machines/renge/services/invidious/0001-Prefer-opus-audio-streams-in-listen-mode.patch index 528a8c3..d4481ae 100644 --- a/machines/renge/services/invidious/0001-Prefer-opus-audio-streams-in-listen-mode.patch +++ b/machines/renge/services/invidious/0001-Prefer-opus-audio-streams-in-listen-mode.patch @@ -1,33 +1,46 @@ -From c8fa5a9b2fd5f4a9a5fe3b1e0876702a1d6dd5e2 Mon Sep 17 00:00:00 2001 +From 237067e0b6bf005763090a6b063daa3bc4bb8d90 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Thu, 9 Sep 2021 16:56:57 +0200 Subject: [PATCH] Prefer opus audio streams in listen mode --- - src/invidious/views/components/player.ecr | 10 ++++++++++ - 1 file changed, 10 insertions(+) + src/invidious/views/components/player.ecr | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr -index fffefc9a..9c9ce553 100644 +index c3c02df0..3278bcba 100644 --- a/src/invidious/views/components/player.ecr +++ b/src/invidious/views/components/player.ecr -@@ -7,6 +7,16 @@ +@@ -7,14 +7,14 @@ <% else %> <% if params.listen %> -+ <% -+ opus_streams = audio_streams.select { |fmt| -+ metadata = itag_to_metadata?(fmt["itag"]) -+ metadata ? metadata["acodec"] == "opus" : false -+ }.reverse! -+ if opus_streams.size > 0 -+ audio_streams = opus_streams -+ end -+ audio_streams.sort_by! { |fmt| fmt["bitrate"].as_i }.reverse! -+ %> - <% audio_streams.each_with_index do |fmt, i| - src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}" - src_url += "&local=true" if params.local +- <% # default to 128k m4a stream +- best_m4a_stream_index = 0 +- best_m4a_stream_bitrate = 0 ++ <% # default to 128k opus stream ++ best_opus_stream_index = 0 ++ best_opus_stream_bitrate = 0 + audio_streams.each_with_index do |fmt, i| + bandwidth = fmt["bitrate"].as_i +- if (fmt["mimeType"].as_s.starts_with?("audio/mp4") && bandwidth > best_m4a_stream_bitrate) +- best_m4a_stream_bitrate = bandwidth +- best_m4a_stream_index = i ++ if (fmt["mimeType"].as_s.starts_with?("audio/opus") && bandwidth > best_opus_stream_bitrate) ++ best_opus_stream_bitrate = bandwidth ++ best_opus_stream_index = i + end + end + +@@ -25,7 +25,7 @@ + bitrate = fmt["bitrate"] + mimetype = HTML.escape(fmt["mimeType"].as_s) + +- selected = (i == best_m4a_stream_index) ++ selected = (i == best_opus_stream_index) + %> + + <% if !params.local && !CONFIG.disabled?("local") %> -- -2.33.3 +2.36.0