Skip to content

Add cover art and other metadata to downloaded files#13023

Draft
TobiGr wants to merge 16 commits intoTeamNewPipe:refactorfrom
TobiGr:downloader-meta
Draft

Add cover art and other metadata to downloaded files#13023
TobiGr wants to merge 16 commits intoTeamNewPipe:refactorfrom
TobiGr:downloader-meta

Conversation

@TobiGr
Copy link
Copy Markdown
Contributor

@TobiGr TobiGr commented Jan 9, 2026

What is it?

  • Feature (user facing) ⚠️ Your PR must target the refactor branch

Description of the changes in your PR

This PR adds support for thumbnails / cover arts for downloaded mp3, mp4 and opus/ogg files.
Metadata support for mp3 and mp4 files is also added. Side note: mp4/MPEG-4 sucks implementation wise because there are a lot of magic bytes.

This PR fixes the image tags in DescriptionFragments which previously displayed the image dimensions using height x width. This has been changed to the commonly used format width x height.

To do

⚠️ This PR is in an early stage as is supposed to be used for testing only atm.

  • Changes need to be tested with different players and devices
  • mp4 changes are not trivial and need to be tested in detail
  • fetch cover art properly and use reliable async implementation.
  • Add SPDX-License identifier to new files
  • Add more documentation to make the postprocessing more understandable
  • Enable users to disabled metadata embedding

Before/After Screenshots/Screen Record

File format Preview (before) Preview (after) Metadata (before) Metadata (after)
opus+vorbis/ogg/oga none / file icon grafik comment, title, artist, genre, date comment, title, artist, genre, date, album, tracknumber, preformer, organization, copyright
mp3 none / file icon grafik - comment, title, artist, genre, date, album, tracknumber, preformer, organization, copyright
mp4 grafik (first frame) grafik - title, artist, genre, date, label, copyright
mp4 - from dash (first frame) grafik title, artist, genre, date title, artist, genre, date, label, copyright

Fixes the following issue(s)

Closes #4341

Relies on the following changes

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

Notice regarding AI usage

AI (ChatGPT 5 mini) was used to generate some helpers and especially to write Mp4Metadata to correctly adjust the existing udta and following boxes when inserting new data into udta.

@TobiGr TobiGr added feature request Issue is related to a feature in the app downloader Issue is related to the downloader labels Jan 9, 2026
@github-actions github-actions bot added the size/large PRs with less than 750 changed lines label Jan 9, 2026
@TobiGr TobiGr changed the title Add support for more cover arts / thumbnails and other metadata for mp4 and opus/ogg downloads Add support for cover art and other metadata for mp4 and ogg downloads Jan 9, 2026
@TobiGr TobiGr force-pushed the downloader-meta branch 5 times, most recently from dbdd1dc to 3ebf7c7 Compare January 9, 2026 05:25
@TobiGr TobiGr changed the title Add support for cover art and other metadata for mp4 and ogg downloads Add support for cover art and other metadata for mp4 and opus downloads Jan 10, 2026
@TobiGr TobiGr changed the title Add support for cover art and other metadata for mp4 and opus downloads Support cover art and other metadata in mp4 and opus downloads Jan 10, 2026
@cynthia2006

This comment was marked as off-topic.

@cynthia2006
Copy link
Copy Markdown

Using the debug build of NewPipe with this commit resulted in the following exception, perhaps due to thumbnail size overflowing the limits of an OGG page.

Exception

  • User Action: download post-processing
  • Request: https://www.youtube.com/watch?v=gY1WyUIabCc [ {type=audio format=WebM Opus bitrate=160} ]
  • Content Country: IN
  • Content Language: en-IN
  • App Language: en_IN
  • Service: YouTube
  • Timestamp: 2026-01-15T18:10:37.835+05:30
  • Package: org.schabi.newpipe.debug.downloadermeta
  • Service: YouTube
  • Version: 0.28.0
  • OS: Linux samsung/m35xins/m35x:16/BP2A.250605.031.A3/M356BXXU5CYI8:user/release-keys 16 - 36
Crash log

java.lang.UnsupportedOperationException: page size is 73906 but cannot be larger than 65025
	at org.schabi.newpipe.streams.OggFromWebMWriter.addPacketSegment(OggFromWebMWriter.java:519)
	at org.schabi.newpipe.streams.OggFromWebMWriter.build(OggFromWebMWriter.java:214)
	at us.shandian.giga.postprocessing.OggFromWebmDemuxer.process(OggFromWebmDemuxer.java:41)
	at us.shandian.giga.postprocessing.Postprocessing.run(Postprocessing.java:195)
	at us.shandian.giga.get.DownloadMission.doPostprocessing(DownloadMission.java:718)
	at us.shandian.giga.get.DownloadMission.$r8$lambda$IA0_L2vJSLZLqg0BQARF8wvRshk(Unknown Source:0)
	at us.shandian.giga.get.DownloadMission$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
	at java.lang.Thread.run(Thread.java:1119)

@TobiGr
Copy link
Copy Markdown
Contributor Author

TobiGr commented Feb 6, 2026

thanks for testing. I added thumbnail compression and resizing to make thumbnails always fit into one page. Another solution would be to make the metadata spread over multiple pages. I tried to implement this, but was not successful. I ended up receiving corrupted files which does not make things better).

@TobiGr TobiGr force-pushed the downloader-meta branch 2 times, most recently from a2ff809 to 1eea521 Compare February 6, 2026 17:37
@cynthia2006
Copy link
Copy Markdown

Maybe compressing thumbnails isn't the best idea, and we should rather span the data across multiple Ogg pages? That would be on par what libraries like mutagen do, which is used in yt-dlp.

@cynthia2006
Copy link
Copy Markdown

cynthia2006 commented Feb 6, 2026

Besides, it would be neat if we could extract song metadata from the description (with regular expressions) to support YouTube Music. YTDLnis for example does this already using yt-dlp underneath.

@TobiGr TobiGr force-pushed the downloader-meta branch 2 times, most recently from cef47ae to 9e6454f Compare February 6, 2026 22:34
@TobiGr
Copy link
Copy Markdown
Contributor Author

TobiGr commented Feb 6, 2026

Another solution would be to make the metadata spread over multiple pages. I tried to implement this, but was not successful. I ended up receiving corrupted files which does not make things better).

It turned out that I did not fill the last comment page correctly. This works now as expected and high res thumbnails / cover arts are used.

@TobiGr TobiGr force-pushed the downloader-meta branch 2 times, most recently from 100e315 to 95d1997 Compare February 6, 2026 23:21
@cynthia2006
Copy link
Copy Markdown

As a preliminary example, this regular expression could be used to extract information from the description of YouTube Music videos.

YTMUSIC_RE = r'''Provided to YouTube by (?P<label>.+)

.+\u00b7\s(?P<artist>\w+)

(?P<title>.+)

.+

Released on: (?P<date>[\d-]+)''')

Live Example.

@TobiGr TobiGr force-pushed the downloader-meta branch 2 times, most recently from f17b5ae to 1de6b44 Compare February 8, 2026 12:52
@github-actions github-actions bot added the size/giant PRs with more than 750 changed lines label Feb 8, 2026
@github-actions github-actions bot removed the size/large PRs with less than 750 changed lines label Feb 8, 2026
@TobiGr
Copy link
Copy Markdown
Contributor Author

TobiGr commented Feb 8, 2026

I now added support for non-dash mp4 downloads which are e.g. served by PeerTube.

Metadata for songs from YouTube are used now, too. However, YouTube does not provide sqaure thumbnails for YouTube Music streams. This causes album covers to look wrong. YT Music cover arts are now cropped to squares.

@TobiGr TobiGr changed the title Support cover art and other metadata in mp4 and opus downloads Support cover art and other metadata in mp4 and ogg downloads Feb 8, 2026
@TobiGr TobiGr changed the title Support cover art and other metadata in mp4 and ogg downloads Add cover art and other metadata to downloaded files Feb 9, 2026
@TobiGr TobiGr force-pushed the downloader-meta branch 2 times, most recently from 282fced to 41c6bb0 Compare February 9, 2026 21:16
@TobiGr
Copy link
Copy Markdown
Contributor Author

TobiGr commented Feb 9, 2026

Metadata and cover art are now added to mp3 files, too

Comment on lines +38 to +42
fun getGenre(): String? = if (songInfo?.genre?.isEmpty() == false) {
songInfo.genre
} else {
streamInfo.category
}
Copy link
Copy Markdown

@ghost ghost Feb 10, 2026

Choose a reason for hiding this comment

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

I know it is raw and it is not time for review and etc. I probably just won't open it again so comment now.
All these if which checks for isEmpty/isBlank providing default value can be replaced with ifEmpty/ifBlank one liners sonfInfo?.genre?.ifEmpty { songInfo.category }

@ghost
Copy link
Copy Markdown

ghost commented Feb 10, 2026

What media player is recommended for testing? Because vlc weirdly doesn't see cover (while stock gallery app sees it)

@TobiGr
Copy link
Copy Markdown
Contributor Author

TobiGr commented Feb 21, 2026

I can see thumbnails for video and audio files in VLC. Are they enabled in your VLC settings (settings > Interface > Video thumbnails)?

height x width was used before which is an uncommon order.
Copyright, record label, album, label, ...
Extract MP4 metadata (udta) generation into separate helper class
Serialization is attempted if something crashes. Bitmap cannot be serialized.
Metadata embedding is disabled by default across all post-processing algorithms.

A new parameter and variable is introduced although there is the parameter 'args' already. The information on whether the metadata is going to be embedded needs to be parsed by every audio or video post-processing algorithm anyway. Getting it from the list is more difficult and less error-prone than creating a new param.
Update NewPipe Extractor for SongMetadata support
@ghost
Copy link
Copy Markdown

ghost commented Feb 25, 2026

I can see thumbnails for video and audio files in VLC. Are they enabled in your VLC settings (settings > Interface > Video thumbnails)?

Yeah it is enabled. I also hope we are both talking about androids vlc


If you previously read the message or read it on email from github notifications, don't mind it. Your PR wasn't guilty for the crash

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/giant PRs with more than 750 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants