Skip to content

Rework video quality representation and stream selection refactor#13333

Merged
Idadelveloper merged 4 commits intoTeamNewPipe:refactorfrom
evermind-zz:rework-video-quality-representation-and-stream-selection_refactor
Apr 3, 2026
Merged

Rework video quality representation and stream selection refactor#13333
Idadelveloper merged 4 commits intoTeamNewPipe:refactorfrom
evermind-zz:rework-video-quality-representation-and-stream-selection_refactor

Conversation

@evermind-zz
Copy link
Copy Markdown
Contributor

What is it?

  • Bugfix (user facing)
  • Feature (user facing) ⚠️ Your PR must target the refactor branch
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • The first commit just converts ListHelper to kotlin.
  • The 2nd commit: Introduce structured video quality representation and refactor stream selection

Here is the more detail description of the 2nd commit:

This PR replaces the previous string-based resolution/fps/etc. handling for VideoStreams
by parsing the 'getResolution()'-string into a data class to improve maintainability.

Video resolutions (e.g. "720p60") were previously compared and matched using
regex-based string manipulation all over the place. This was fragile,
required repeated parsing and made it difficult to extend the matching logic.

It can handle all the strings like before: "720p", "720p60"

Additionally this patch can also handle strings like: "720p60@123k", or "720p@2m"
I know this feature is not (yet) needed for NewPipe but is used in my fork BravePipe
and does not hurt anyone.

Main changes:

  • Introduce internal data class VideoQuality (resolution, fps, bitrate, formatRank).
  • Introduce internal VideoStreamWithQuality to associate streams with parsed quality.
  • Parse quality only once.
  • Replace resolution string sorting with a comparator based on
    resolution -> fps -> formatRank -> bitrate.
  • Rework stream selection to use a priority-based matching algorithm
    (format, resolution, fps, bitrate).
  • Prefer candidates with bitrate closest to the requested one when multiple
    streams match the same priority class.

Further notes:

  • All unit tests of ListHelperTest run fine.
  • could be backported with no changes I guess

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

@github-actions github-actions Bot added the size/giant PRs with more than 750 changed lines label Mar 11, 2026
@TobiGr TobiGr added player Issues related to any player (main, popup and background) code quality Improvements to the codebase to improve the code quality rewrite Issues and PRs related to rewrite labels Mar 11, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in Rewrite Mar 11, 2026
evermind-zz and others added 4 commits April 2, 2026 10:29
…tion

Replace the previous string-based resolution/fps/etc. handling for VideoStreams
by parsing the 'getResolution()'-string to a data class to improve maintainability.

Video resolutions (e.g. "720p60") were previously compared and matched using
regex-based string manipulation all over the place. This was fragile,
required repeated parsing and made it difficult to extend the matching logic.

It can handle all the strings like before: "720p", "720p60"

Additionally this patch can also handle strings like: "720p60@123k", or "720p@2m"

Main changes:
- Introduce internal data class VideoQuality (resolution, fps, bitrate, formatRank).
- Introduce internal VideoStreamWithQuality to associate streams with parsed quality.
- Parse quality only once.
- Replace resolution string sorting with a comparator based on
  resolution -> fps -> formatRank -> bitrate.
- Rework stream selection to use a priority-based matching algorithm
  (format, resolution, fps, bitrate).
- Prefer candidates with bitrate closest to the requested one when multiple
  streams match the same priority class.
@Idadelveloper Idadelveloper force-pushed the rework-video-quality-representation-and-stream-selection_refactor branch from a1d6e91 to 0e2e94d Compare April 3, 2026 13:35
@Idadelveloper Idadelveloper merged commit 44bf345 into TeamNewPipe:refactor Apr 3, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Rewrite Apr 3, 2026
@TobiGr
Copy link
Copy Markdown
Contributor

TobiGr commented Apr 3, 2026

@evermind-zz @Idadelveloper thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality Improvements to the codebase to improve the code quality player Issues related to any player (main, popup and background) rewrite Issues and PRs related to rewrite size/giant PRs with more than 750 changed lines

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants