TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
31k stars 3.02k forks source link

Add metadata while downloading files #4341

Open indahud opened 3 years ago

indahud commented 3 years ago

Add metadata and thumbnail while downloading files

There is no option to embed metadata and thumbnails while downloading files.

Is your feature request related to a problem? Please describe it

No

How will you/everyone benefit from this feature?

Metadata information like chapters, artist, album name, genre, year and thumbnail can organize audio files easily. Similarly for video files.

opusforlife2 commented 3 years ago

I'm surprised this isn't a duplicate. There is literally no issue asking for metadata to be added to downloads. O.o

How does youtube-dl do it?

Regarding thumbnails, they can only be added to the mp4 container, not ogg. (Technically they can, but it needs a hack; the image needs to be converted to base64 or something.)

opusforlife2 commented 3 years ago

Metadata can and should be added for audio as well as video files.

B0pol commented 3 years ago

youtube-dl doesn't add metadata by default, but you can with --add-metadata option.

indahud commented 3 years ago

It uses these flags --embed-thumbnail --add-metadata

MD77MD commented 3 years ago

this would be very cool... especially for audio files

AndroidDeveloperLB commented 3 years ago

@B0pol And it will add the image too? In full quality?

I'm here from a request I wrote here, btw: https://github.com/TeamNewPipe/NewPipe/issues/1014

opusforlife2 commented 3 years ago

It would not be a good idea to add a very high quality image to the downloaded file. If your file is 4 MB and you add another 2 MB just to get a thumbnail, for example, it would bloat your media library very fast.

AndroidDeveloperLB commented 3 years ago

@opusforlife2 I don't think I ever saw a ridiculously large image for it that it takes this much space, from YouTube, and I use "mediahuman youtube to mp3 converter" on many videos from there. In fact I never even saw a 4k image from there, so I think it should be safe.

You could always have a setting for protecting it, if you really want:

  1. Disable adding image
  2. add image, only if up to widthxheight resolution. Downscale if needed.
  3. add image, only if up to x MB. Downscale if needed.
  4. add image, only if up to x MP. Downscale if needed.
  5. always add image. No downscaling.

And because I really never saw such an issue.

opusforlife2 commented 3 years ago

https://support.google.com/youtube/answer/72431?hl=en

I got the 2 MB figure from here. So it is possible that an uploader uses an image of that size.

But Youtube provides thumbnails in several sizes. From very small to full sized. That's what I was referring to. We could get an optimum sized image that looks good but is still small.

And yes, we should definitely have a setting to control this. Users who don't want thumbnails shouldn't have to pay for them in data.

AndroidDeveloperLB commented 3 years ago

@opusforlife2 It's the guidelines, and even then, it's incredibly rare for an image of size 1280x720 to take this much space. It will probably need to have such random content that the compression of JPG/PNG will fail to compress it well.

I don't think you need to worry about this much. We could have a generous default setting and you wouldn't notice it.

If you want, you can try to upload the largest thing you can, and I can test what I get from it.

opusforlife2 commented 3 years ago

I'm surprised Youtube doesn't recommend WebP for thumbnails yet. Or even AVIF.

AndroidDeveloperLB commented 3 years ago

@opusforlife2 I don't know how it's saved behind the scenes. Does YouTube have the videos saved in a format that has the image inside? Or it's separate? If it's separate, they might save it on WEBP themselves. If it's inside the video file, maybe it's limited...

opusforlife2 commented 3 years ago

Does YouTube have the videos saved in a format that has the image inside? Or it's separate?

It's separate, probably. They only need thumbnails for embedded videos.

AndroidDeveloperLB commented 3 years ago

@opusforlife2 So maybe it's webp?

AndroidDeveloperLB commented 3 years ago

@opusforlife2 Are there rules about the format, when it's inside the video file? It could be WEBP?

opusforlife2 commented 3 years ago

WebP has a different container called RIFF. https://en.wikipedia.org/wiki/WebP

It doesn't seem to support being contained in WebM or MP4.

So maybe it's webp?

https://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api

This shows several URLs which have thumbnails in the webp format. So Youtube does use them already.

AndroidDeveloperLB commented 3 years ago

@opusforlife2 So on YouTube it's saved as WEBP, but on the output of creating MP4/WEBM, we can't have WEBP inside .

Too bad. So what can be inside MP4/WEBM ? JPG/PNG ? Something else?

opusforlife2 commented 3 years ago

Why would you need embedded thumbnails for videos? They are generally automatically generated by media players like VLC, and file explorers as well.

To answer your question, JPGs and PNGs can be embedded in both those containers. But a likely use for an embedded thumbnail is only audio files, which rules out WebM. This is because Youtube contains only Opus and AAC audio streams, which are downloaded by Newpipe in Ogg and MP4 containers respectively.

I've already written about Ogg here https://github.com/TeamNewPipe/NewPipe/issues/4341#issuecomment-700200109.

AndroidDeveloperLB commented 3 years ago

@opusforlife2 When you download as an audio file, though, I don't think apps will generate it for you. The request here is more about audio, not video. I just asked this as a side note, because it's interesting for both video and audio. It could be nice to have an option for video, too, though.

The same restrictions are for audio? Can't put WEBP into audio files? Only PNG/JPG?

opusforlife2 commented 3 years ago

Nothing matters here except the container. MP4 allows images, and so does WebM (it is based on Matroska - MKV). But not Ogg. In Newpipe's case, only MP4 matters, because you have the option of downloading AAC streams in that container.

AndroidDeveloperLB commented 3 years ago

@opusforlife2 Odd that OGG doesn't support it, as it's supposed to be newer and more modern... I'm sorry if I made you upset. So as you said, whether it's audio or video file, we are restricted to PNG/JPG to be inside?

opusforlife2 commented 3 years ago

What made you think I'm upset?

Odd that OGG doesn't support it

It is indeed weird.

we are restricted to PNG/JPG to be inside?

Yup.

AndroidDeveloperLB commented 3 years ago

@opusforlife2 I see. Thanks.

gl-dev commented 3 years ago

Hi there, I'd also give this feature +1.

It would be very helpful to support and integrate metadata into downloaded files for e.g. a video to podcast scenario including a cover screenshot at a definable position within a video file. The MP4 to M4A conversion is sufficient for me, so I use ffmpeg to achieve that goal.

Save the following commands in a batch file and put a link into the "SendTo" folder (%appdata%\Microsoft\Windows\SendTo) to be able to choose MP4 files in the file-explorer.

REM rip audio track from video file
ffmpeg.exe -i %%a -vn -acodec copy "%%~dpa%%~na".tmp.m4a

REM rip frame at 5s of video with quality 5 to jpg
ffmpeg.exe -i %%a -ss 00:00:05 -vframes 1 -q:v 5 "%%~dpa%%~na".jpg

REM integrate jpg into m4a file and cleanup, if the conversion is executed without errors
ffmpeg.exe -i "%%~dpa%%~na".tmp.m4a -i "%%~dpa%%~na".jpg -map 0:0 -map 1:0 -codec copy -disposition:v:0 attached_pic "%%~dpa%%~na".m4a && del "%%~dpa%%~na".tmp.m4a && del "%%~dpa%%~na".jpg

I'm happy with this, however if NewPipe could do the job automatically, that would be a nice time saver ;)

BruceMustache commented 3 years ago

+1 for that feature

micycle8778 commented 3 years ago

This would be very useful for archivists, like myself, who want a painless way of organizing the videos they have download.

tellmewhy12 commented 3 years ago

I also would really like to see this, because I always end up using another App trying to add tags and sometimes not quite remembering them, having this just done in NewPipe would be amazing. Maybe there should be an option for making metadata optional and cover art optional for people that want to reduce their file size

tellmewhy12 commented 3 years ago

I am still very new to this but an implementation could maybe look like this:

Metadata:

Album Art:

Errors that might occur:

AndroidDeveloperLB commented 3 years ago

@mangoepic By "cover" it means "album cover" , right? Meaning it could get the image from YouTube of the video, and put it into the output file?

tellmewhy12 commented 3 years ago

@AndroidDeveloperLB Yes there needs to be some method for it. I know that youtube-dl can download youtube thumbnails with ffmpeg but i am not sure how well this is supported/customizable without it and if it supports all of newpipes platforms like soundcloud etc.

tellmewhy12 commented 3 years ago

https://github.com/mangoepic/NewPipe i tried starting to add a cover image feature here but i have honestly no idea what i am doing so feel free to help or overtake if you're interested

Mhowser commented 2 years ago

Is it possible to bundle youtube-dl and ffmpeg with newpipe? (Or they can be downloaded and installed via option in settings). Then there could be an "advanced download" section where users can add their own custom youtube-dl command.

opusforlife2 commented 2 years ago

@Mhowser You can search for those keywords. This has already been discussed.

tellmewhy12 commented 2 years ago

My current idea was to use jaudiotagger (or similiar) for tagging and getting the current youtube thumbnail as cover + inserting the channel as artist and the video title as Music title.

iBabu007 commented 2 years ago

When this feature implemented?

DarkShadow4 commented 1 year ago

Has this been solved finally?

khimaros commented 9 months ago

this is a subset of the issue described here, but it would be helpful to embed the original download URI into the metadata as well. this is helpful for archival/provenance.

rajarshikhatua100 commented 7 months ago

I mean Ymusic on Android somehow does it

foxjaw commented 6 months ago

I believe this should also include chapters.

khimaros commented 4 months ago

workaround: install YTDLNis (available from Github or IzzyOnDroid) and use the android share dialog to share to YTDLNis. from there you can control all parameters of the download including custom yt-dlp flags.

foxjaw commented 4 months ago

Already used it btw. I thought why two apps for two different tasks, when the np extractor has the ability to fetch these streams and has a post-processor isn't it ? This is a feature enhancement anyways.

rajarshikhatua100 commented 4 months ago

workaround: install YTDLNis (available from Github or IzzyOnDroid) and use the android share dialog to share to YTDLNis. from there you can control all parameters of the download including custom yt-dlp flags.

It is super slow, takes too much time to just start the download

foxjaw commented 4 months ago

It is super slow, takes too much time to just start the download

Try enabling aria2 from the settings.