NewPipe icon indicating copy to clipboard operation
NewPipe copied to clipboard

Add metadata while downloading files

Open indahud opened this issue 4 years ago • 43 comments

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.

indahud avatar Sep 28 '20 18:09 indahud

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 avatar Sep 28 '20 18:09 opusforlife2

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

opusforlife2 avatar Sep 28 '20 18:09 opusforlife2

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

B0pol avatar Sep 28 '20 18:09 B0pol

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

indahud avatar Sep 28 '20 18:09 indahud

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

MD77MD avatar Sep 28 '20 19:09 MD77MD

@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

AndroidDeveloperLB avatar Sep 29 '20 06:09 AndroidDeveloperLB

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.

opusforlife2 avatar Sep 29 '20 06:09 opusforlife2

@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.

AndroidDeveloperLB avatar Sep 29 '20 06:09 AndroidDeveloperLB

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.

opusforlife2 avatar Sep 29 '20 07:09 opusforlife2

@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.

AndroidDeveloperLB avatar Sep 29 '20 07:09 AndroidDeveloperLB

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

opusforlife2 avatar Sep 29 '20 07:09 opusforlife2

@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...

AndroidDeveloperLB avatar Sep 29 '20 07:09 AndroidDeveloperLB

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.

opusforlife2 avatar Sep 29 '20 07:09 opusforlife2

@opusforlife2 So maybe it's webp?

AndroidDeveloperLB avatar Sep 29 '20 07:09 AndroidDeveloperLB

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

AndroidDeveloperLB avatar Sep 29 '20 07:09 AndroidDeveloperLB

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.

opusforlife2 avatar Sep 29 '20 08:09 opusforlife2

@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?

AndroidDeveloperLB avatar Sep 29 '20 08:09 AndroidDeveloperLB

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.

opusforlife2 avatar Sep 29 '20 09:09 opusforlife2

@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?

AndroidDeveloperLB avatar Sep 29 '20 09:09 AndroidDeveloperLB

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.

opusforlife2 avatar Sep 29 '20 09:09 opusforlife2

@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?

AndroidDeveloperLB avatar Sep 29 '20 09:09 AndroidDeveloperLB

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.

opusforlife2 avatar Sep 29 '20 10:09 opusforlife2

@opusforlife2 I see. Thanks.

AndroidDeveloperLB avatar Sep 29 '20 10:09 AndroidDeveloperLB

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 ;)

gl-dev avatar Oct 11 '20 10:10 gl-dev

+1 for that feature

BruceMustache avatar Nov 30 '20 13:11 BruceMustache

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

micycle8778 avatar Dec 24 '20 03:12 micycle8778

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 avatar Mar 06 '21 10:03 tellmewhy12

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

  • Add a tagging library like jaudiotagger to newpipe http://www.jthink.net/jaudiotagger/ https://github.com/TeamNewPipe/NewPipe/issues/183#issuecomment-186678500

Metadata:

  • New Settings in Settings -> Download -> Add Metadata/Tagging
    • add setting for "Automatically add metadata to file" (yes/no)
    • (optional): "Use format Artist - Title for artist instead of channel name" (yes/no)
  • Add the metadata after file download using the library according to the users configuration
  • This should probably to fast for the user to notice, so wouldn't need any interface changes

Album Art:

  • New checkbox in the download dialogue: "Download Album Cover"
  • The cover gets fetched somehow (maybe youtube-dl i don't know if it supports all platforms correctly)
  • The cover gets downloaded to some temporary destination (This is important so that the user does not get spammed with random images in their music folder from aborted downloads. It should be cleared often, maybe every startup and after finishing merging)
  • After the file (music/video) has downloaded add the cover to the music file using the tagging library
  • If it takes some time signal it somehow on the interfaces download page
  • Delete image from temp folder

Errors that might occur:

  • Can't fetch the cover: Inform user but still download
  • Can't fetch the metadata: Inform user but still download
  • Can't merge the image to the file: Inform user, delete the image
  • Can't download image: ?

tellmewhy12 avatar Mar 31 '21 20:03 tellmewhy12

@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?

AndroidDeveloperLB avatar Mar 31 '21 20:03 AndroidDeveloperLB

@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 avatar Mar 31 '21 21:03 tellmewhy12