Tzahi12345 / YoutubeDL-Material

Self-hosted YouTube downloader built on Material Design
MIT License
2.57k stars 266 forks source link

Embedded thumbnails in mp3 #318

Open alandolt opened 3 years ago

alandolt commented 3 years ago

Hello Tzahi12345 First thanks a lot for the development of YoutubeDL-Material and making it open source. It is a great piece of software to handle youtube-dl and really facilitate my workflow (while also providing a good user interface for my family members to download their beloved YouTube videos). Thanks.

However, during its usage I’ve found unfortanetely a little bug. The embedding of album covers in mp3 does not work. For adding them, I’ve first added the following args in settings -> Downloader -> Custom Args --embed-thumbnail,,--write-thumbnail

The resulting command is then: youtube-dl https://www.youtube.com/watch?v=dQw4w9WgXcQ -o audio/%(title)s.mp3 -x --audio-format mp3 --write-info-json --print-json --embed-thumbnail --write-thumbnail

On the overview of the downloaded files, the cover is visible, however it is not embedded in the mp3 files. In the folder, the thumbnail get downloaded as .jpg, so in theory ffmpeg should be able to embed it. Do you know maybe a fix or is it my fault? Is there another argument which need to be set?

I am using YoutubeDL-Material v4.2 (I’ve also tried the nightly version, however no success either) on docker on a headless Rock64 SBC (so arm64 architecture, thanks by the way for providing arm images).

The debug from youtubedl-material isn’t helpful either:

2021-01-18T18:36:02.656Z VERBOSE: youtube-dl args being used: -o,audio/%(title)s.%(ext)s,--write-info-json,--print-json,-f,bestaudio,-x,--audio-format,mp3,--write-thumbnail,--embed-thumbnail,--write-thumbnail
2021-01-18T18:36:17.689Z DEBUG: URL info retrieval delay: 18.202 seconds.
2021-01-18T18:37:11.473Z DEBUG: Audio download delay: 68.819 seconds.
2021-01-18T18:37:12.214Z DEBUG: Successfully closed stream and removed file reference.

Sorry for not having a more detailed log, however, when I add the verbose switch (--verbose) to the download command, I am receiving an error: ERROR: Error while retrieving info on video with URL https://www.youtube.com/watch?v=djV11Xbc914 with the following message: SyntaxError: Unexpected token d in JSON at position 1

Thank you very much for an answer Best regards Cat Turbo

Tzahi12345 commented 3 years ago

Hi! Glad you like it :)

Regarding the the --verbose arg, it's unfortunately not possible as we rely on the output to be in JSON format and with --verbose it comes out as a bunch of unformatted lines (notice --print-json is used).

I had trouble embedding thumbnails as well, but I found a neat arg that (for some reason) seemed to fix everything:

--postprocessor-args,,-id3v2_version 3 (source)

I tested it and it seems to work! Let me know if it does on your end as well. If so I may just add that arg automatically if --embed-thumbnail is used.

alandolt commented 3 years ago

Thanks for your fast and helpfull answer. Unfortanately it stills does not work at my end, even with the added --postprocessor-args. I've tried the full command on windows and it did work to download the video, extract the audio and embed the thumbnail: youtube-dl https://www.youtube.com/watch?v=i119LgMDIXI -o '%(title)s.mp3' -x --audio-format mp3 --embed-thumbnail --postprocessor-args "-write_id3v1 1 -id3v2_version 3" --add-metadata

However, the embeding of the thumbnails does not work with the same command in the YoutubeDL-material webinterface.
Here are my custom args settings: --embed-thumbnail,,--postprocessor-args,,-write_id3v1 1 -id3v2_version 3,,--add-metadata

and the simulated command, copied from the extended tab: youtube-dl -o audio/%(title)s.mp3 -x --audio-format mp3 --write-info-json --print-json --embed-thumbnail --postprocessor-args -write_id3v1 1 -id3v2_version 3 --add-metadata

Do I maybe have to add the value of the postprocessor-args with '' (tried it with " ", but gave me a parsing error). What did you exactly enter in the webinterface to make it work? Thanks for your answer.

Tzahi12345 commented 3 years ago

Thanks for your fast and helpfull answer.

It's a pleasure, in fact a few days is a bit slow for me lol

I didn't do the quotes, this is what I put in my global custom args:

--embed-thumbnail,,--postprocessor-args,,-id3v2_version 3

I don't think you need -write_id3v1 1 (maybe it's only needed for legacy devices?), does it work with what I wrote above?

EDIT:

Actually if you want to keep -write_id3v1 1 perhaps you can do this:

--embed-thumbnail,,--postprocessor-args,,-write_id3v1 1,,-id3v2_version 3,,--add-metadata

or

--embed-thumbnail,,--postprocessor-args,,-write_id3v1,,1,,-id3v2_version 3,,--add-metadata

alandolt commented 3 years ago

Hmm, sorry I am still struggling. I've tried it with your provided global custom args, and thumbnail embeding still doesn't work either. --embed-thumbnail,,--postprocessor-args,,-id3v2_version 3

Is it maybe possible that I need to parse the space character between version and 3 with something, like you've tried it for the -write_id3_v1,,1 (but separation with comma doesn't work, gives a download failure). Or is the problem maybe related with the architecture (I know that would be very strange, but maybe ffmpeg does not have thumbmail embeding in arm builds)?

Edit: I'v created the docker container also on a system with AMD64 architecture (with windows 10 as host system, docker deamon over WSL, sorry, I don't have currently an AMD64 linux system to test with ;) ). But the bug remains, so we can conclude that there is not a problem with ffmpeg on ARM64.

jkexbx commented 1 year ago

Thanks for your fast and helpfull answer.

It's a pleasure, in fact a few days is a bit slow for me lol

I didn't do the quotes, this is what I put in my global custom args:

--embed-thumbnail,,--postprocessor-args,,-id3v2_version 3

I don't think you need -write_id3v1 1 (maybe it's only needed for legacy devices?), does it work with what I wrote above?

EDIT:

Actually if you want to keep -write_id3v1 1 perhaps you can do this:

--embed-thumbnail,,--postprocessor-args,,-write_id3v1 1,,-id3v2_version 3,,--add-metadata

or

--embed-thumbnail,,--postprocessor-args,,-write_id3v1,,1,,-id3v2_version 3,,--add-metadata

Do you know if this is still supposed to work? When I try the custom args in a subscription I get "youtube-dl: error: no such option: -d"

--embed-thumbnail,,--postprocessor-args,,-id3v2_version 3

It does work when put in global custom args