Skip to content

Add IsVideoUpscaled property to IVideoStreamInfo to detect AI-upscaled streams#950

Merged
Tyrrrz merged 24 commits intoprimefrom
copilot/detect-ai-upscaled-video-qualities
Apr 22, 2026
Merged

Add IsVideoUpscaled property to IVideoStreamInfo to detect AI-upscaled streams#950
Tyrrrz merged 24 commits intoprimefrom
copilot/detect-ai-upscaled-video-qualities

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

  • Fix IsVideoUpscaled detection: use xtags protobuf "sr" key instead of quality label
  • Move IsVideoUpscaled from VideoQuality to IVideoStreamInfo and its implementations
  • Refactor xtags parsing: replace raw byte scan with a proper protobuf map parser
  • Extract protobuf parsing into Utils.Protobuf returning IReadOnlyDictionary<string, string?>
  • Rename TryDeserializeTryDeserializeMap to make intent clear
  • Change TryReadVarint and TryReadString to return nullable values instead of out params + bool
  • Sort overloads so primary TryReadVarint + TryDeserializeMap(byte[]) appear before the caller TryDeserializeMap(string)
  • Use GetValueOrDefault instead of TryGetValue in PlayerResponse
  • Add IsLenField(ulong tag) helper for wire-type 2 checks in Protobuf
  • Add TryReadString helper for string field reading in Protobuf
  • Use var everywhere in Protobuf.cs
  • Rename IsUpscaledIsVideoUpscaled in IVideoStreamInfo, VideoOnlyStreamInfo, MuxedStreamInfo, and tests
  • Revert unnecessary change in VideoQuality.FromItag (back to 2-param constructor)
  • Move IsVideoUpscaled to after VideoHeight (and before VideoFramerate) in IStreamData, PlayerResponse.StreamData, and DashManifest.StreamData; already after VideoResolution in IVideoStreamInfo, VideoOnlyStreamInfo, and MuxedStreamInfo
  • Add backwards-compatible constructor overloads to VideoOnlyStreamInfo and MuxedStreamInfo (without isVideoUpscaled, defaulting to false)

Copilot AI linked an issue Apr 21, 2026 that may be closed by this pull request
4 tasks
Copilot AI changed the title [WIP] Add detection for AI-upscaled video qualities in stream metadata Add IsUpscaled property to VideoQuality to detect AI-upscaled streams Apr 21, 2026
Copilot AI requested a review from Tyrrrz April 21, 2026 11:21
@Tyrrrz
Copy link
Copy Markdown
Owner

Tyrrrz commented Apr 21, 2026

@copilot tests are failing. Are you sure Label is meant to contain AI?

If I had to guess, the new metadata should be inside the player response. Try changing the code to dump the response to a file and analyze it to find if there's anything related to upscaling, super-resolution, or AI enhansion.

Copilot AI and others added 2 commits April 21, 2026 17:47
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 21, 2026

@copilot tests are failing. Are you sure Label is meant to contain AI?

If I had to guess, the new metadata should be inside the player response. Try changing the code to dump the response to a ...

You were right — the quality label stays plain (e.g. "1080p") with no "AI" suffix. The actual marker is the xtags field in the format object, which is a base64-encoded protobuf map<string, string>. For AI super-resolution streams it contains the entry {"sr": "1"}, while non-upscaled streams have no xtags field at all (confirmed by the player response JSON you shared).

Fixed in fa0fe12: IsVideoUpscaled is now detected by decoding the xtags base64 bytes and scanning for the protobuf-encoded "sr" key (0x0a 0x02 0x73 0x72). VideoQuality.IsUpscaled is now a stored boolean populated from that flag rather than a label-string check.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.youtube.com
    • Triggering command: /usr/bin/python3 python3 /tmp/yt_investigate/investigate.py (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Comment thread YoutubeExplode/Videos/Streams/VideoQuality.cs Outdated
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 21, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • av-build-tel-api-v1.avaloniaui.net
    • Triggering command: /usr/share/dotnet/dotnet dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.2/tools/netstandard2.0/runtimeconfig.json /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.2/tools/netstandard2.0/Avalonia.BuildServices.Collector.dll (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add IsUpscaled property to VideoQuality to detect AI-upscaled streams Add IsUpscaled property to IVideoStreamInfo to detect AI-upscaled streams Apr 21, 2026
Copilot AI requested a review from Tyrrrz April 21, 2026 18:03
Comment thread YoutubeExplode/Bridge/DashManifest.cs Outdated
Comment thread YoutubeExplode/Bridge/PlayerResponse.cs Outdated
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 21, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • av-build-tel-api-v1.avaloniaui.net
    • Triggering command: /usr/share/dotnet/dotnet dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.2/tools/netstandard2.0/runtimeconfig.json /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.2/tools/netstandard2.0/Avalonia.BuildServices.Collector.dll (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Tyrrrz and others added 2 commits April 22, 2026 13:46
Comment thread YoutubeExplode/Utils/Protobuf.cs Outdated
Agent-Logs-Url: https://github.com/Tyrrrz/YoutubeExplode/sessions/35a1c857-b109-4038-9bc4-5a31d76d3caa

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copilot AI requested a review from Tyrrrz April 22, 2026 10:53
… and MuxedStreamInfo

Agent-Logs-Url: https://github.com/Tyrrrz/YoutubeExplode/sessions/37203393-1071-48ff-908c-202989cff48f

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread YoutubeExplode/Utils/Protobuf.cs Outdated
Comment thread YoutubeExplode/Utils/Protobuf.cs
Comment thread YoutubeExplode/Utils/Protobuf.cs
Tyrrrz and others added 2 commits April 22, 2026 14:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Tyrrrz Tyrrrz merged commit 79aee02 into prime Apr 22, 2026
7 checks passed
@Tyrrrz Tyrrrz deleted the copilot/detect-ai-upscaled-video-qualities branch April 22, 2026 11:24
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (33eef87) to head (f55b58a).
⚠️ Report is 1 commits behind head on prime.

Additional details and impacted files
@@     Coverage Diff      @@
##   prime   #950   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect AI-upscaled video qualities

3 participants