Skip to content

Feat: opus metadata encoding#12974

Merged
TobiGr merged 4 commits intoTeamNewPipe:refactorfrom
mira-x:feat-opus-metadata
Jan 3, 2026
Merged

Feat: opus metadata encoding#12974
TobiGr merged 4 commits intoTeamNewPipe:refactorfrom
mira-x:feat-opus-metadata

Conversation

@mira-x
Copy link
Contributor

@mira-x mira-x commented Dec 30, 2025

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

With this patch, downloaded .opus audio files will contain basic metadata (see example below). This is not a directly visible change, but comes in handy when you use downloaded audio with media players.

Here is the ffprobe output of a downloaded file that shows all tags that were added.

Input #0, ogg, from 'Boney M. - Sunny (Official Audio).opus':
  Duration: 00:04:02.87, start: 0.007500, bitrate: 127 kb/s
  Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp, start 0.007500
    Metadata:
      COMMENT         : Downloaded using NewPipe 0.28.0 on 2025-12-30T14:29:11.091+01:00;URL: https://www.youtube.com/watch?v=ghGiv7YLC7Q
      GENRE           : Music
      ARTIST          : BoneyMVEVO
      TITLE           : Boney M. - Sunny (Official Audio)
      DATE            : 2020-08-07

(On a side note, I thought about adding metadata encoding to m4a downloads as well. But after some research, I figured that this is a nontrivial change)

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

This adds a simple timestamp to downloaded opus files in the form of a COMMENT tag.
This adds content-aware metadata tags to downloaded opus files. Previously, only a static string with a timestamp was added.
@github-actions github-actions bot added the size/medium PRs with less than 250 changed lines label Dec 30, 2025
@TobiGr TobiGr added feature request Issue is related to a feature in the app downloader Issue is related to the downloader labels Dec 30, 2025
@TobiGr TobiGr self-requested a review December 31, 2025 08:49
Copy link
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

Thank you for the PR.

@mira-x
Copy link
Contributor Author

mira-x commented Jan 1, 2026

Hi, thanks for your review. You have some good points. But I disagree on the comment tag.

I can see that the NewPipe version and download date do not add value for the user. But the source URL is very useful. For instance, when you want to see the music video of a song you downloaded, or when you want to see the video of a downloaded podcast. Encoding the URL into the metadata is the reason why I made this PR, and I don't see how this would obstruct the user.

Would you prefer using a different tag? The Opus standard contains no standard tag for the source of an audio. That's why I chose the COMMENT tag. But the tags are formless, so one could use a custom one. See this RFC.

This simplifies the code by not serializing and de-serializing the tags data, and also removes the DownloadManagerService.EXTRA_SOURCE field, which is always inferred from the StreamInfo.
@mira-x mira-x requested a review from TobiGr January 2, 2026 17:38
@mira-x
Copy link
Contributor Author

mira-x commented Jan 2, 2026

I have added and tested your proposed changes, but I kept the bare URL in the comment tag for now.

Copy link
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

Thank you. LGTM, just a small nitpick

@mira-x mira-x requested a review from TobiGr January 3, 2026 10:14
@mira-x
Copy link
Contributor Author

mira-x commented Jan 3, 2026

I have implemented this change, and it does not exceed the line limit.

Copy link
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

thank you

final var metadata = new ArrayList<Pair<String, String>>();
if (streamInfo != null) {
metadata.add(Pair.create("COMMENT", streamInfo.getUrl()));
metadata.add(Pair.create("GENRE", streamInfo.getCategory()));
Copy link
Contributor

Choose a reason for hiding this comment

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

The genre should only be set if getCategory() is not empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line 357 of OggFromWebMWriter.java filters out empty tags. Have you tested this and found that this filter does not work? I have not yet come across a video without a category, so I might be wrong.

@TobiGr TobiGr merged commit 3369607 into TeamNewPipe:refactor Jan 3, 2026
8 of 9 checks passed
TobiGr pushed a commit that referenced this pull request Jan 3, 2026
Feat: Downloading: Add opus audio metadata tags for title, author, date, and a comment tag with the originating URL

This removes the DownloadManagerService.EXTRA_SOURCE field, which is always inferred from the StreamInfo.
@TobiGr TobiGr mentioned this pull request Jan 3, 2026
4 tasks
@TobiGr
Copy link
Contributor

TobiGr commented Jan 3, 2026

I backported this to 0.28.1

@mira-x mira-x deleted the feat-opus-metadata branch January 3, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

downloader Issue is related to the downloader feature request Issue is related to a feature in the app size/medium PRs with less than 250 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants