Modern Apps git

← Modern-Apps.git

youpipe: preserve 60fps when preferring vp9 over avc

Commit
0440f20afba6ae7808b10be5f10e6a2e70c9b8c2
Author
Vayun Mathur <[email protected]>
When
2026-07-23 17:39 UTC (4 months ago)
Parents
edbab88
Previous groupBy height-only dedup dropped 60fps if, e.g., 1080p vp9@30fps
and 1080p avc@60fps both existed -> all avc filtered, losing 60fps variant.

Now groupBy (height to fps), so vp9 preferred over avc only within same
resolution+fps bucket. 60fps streams kept correctly.

Also keeps high res (>1080p) and fps variants via distinctBy Triple(codec,height,fps).

Diff

youpipe/src/main/java/com/vayunmathur/youpipe/util/YouPipeViewModel.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/util/YouPipeViewModel.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/util/YouPipeViewModel.ktindex c5a2c60102..62566260eb 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/util/YouPipeViewModel.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/util/YouPipeViewModel.kt@@ -713,25 +713,25 @@ class YouPipeViewModel(                         }                          if (progVideoOnly.isNotEmpty() || sabrVideoOnly.isNotEmpty()) {-                            // Combine progressive + SABR video-only. Deduplicate by height and prefer-                            // vp9 over avc for same resolution (per user request). AV1 is kept when-                            // present as distinct quality. Opus-only audio. Do NOT filter >1080p.+                            // Combine progressive + SABR video-only. For same resolution+fps,+                            // if vp9 and avc both exist, keep only vp9 (user request). This preserves+                            // 60fps streams even when only avc has 60fps and vp9 has 30fps.+                            // AV1 is kept as distinct codec. Do NOT filter >1080p.                             val combinedVideo = (                                 progVideoOnly.map { it.toDomain() } +                                     sabrVideoOnly.map { it.toSabrDomain(videoId) }                                 )-                                .groupBy { it.height }-                                .flatMap { (_, streamsAtHeight) ->-                                    val vp9 = streamsAtHeight.filter { it.codec == "vp9" }-                                    val avc = streamsAtHeight.filter { it.codec == "avc" }-                                    // If both vp9 and avc exist at same height, keep only vp9-                                    if (vp9.isNotEmpty() && avc.isNotEmpty()) {-                                        streamsAtHeight.filter { it.codec != "avc" }+                                .groupBy { it.height to it.fps }+                                .flatMap { (_, streamsAtResFps) ->+                                    val hasVp9 = streamsAtResFps.any { it.codec == "vp9" }+                                    val hasAvc = streamsAtResFps.any { it.codec == "avc" }+                                    if (hasVp9 && hasAvc) {+                                        streamsAtResFps.filter { it.codec != "avc" }                                     } else {-                                        streamsAtHeight+                                        streamsAtResFps                                     }                                 }-                                // Keep different fps as distinct (e.g. 1080p30 vs 1080p60)+                                // Keep different codec at same height/fps as distinct (e.g. av1 vs vp9 at 1080p60)                                 .distinctBy { Triple(it.codec, it.height, it.fps) }                                 .sortedWith(                                     compareByDescending<VideoStream> { it.height }