Vituvo
Vituvo

Reputation: 1048

Youtube-dl on Ubuntu 16.04 not embedding thumbnail to mp3 but creates the mp3 while using bash script

Ubuntu 16.04
Bash 4.4.0

Here is my /etc/youtube-dl.conf

--force-ipv4
--ignore-errors
--prefer-ffmpeg
--no-mtime
--add-metadata
--write-all-thumbnails
--extract-audio
--format bestaudio
--audio-format mp3
--audio-quality 0
--embed-thumbnail
--restrict-filenames
--cache-dir="/scripts/tools/youtube-dl/.cache"
-o "/scripts/tools/youtube-dl/.music-folder/%(title)s-%(id)s.%(ext)s"

Here is my error:

[debug] System config: ['--force-ipv4', '--ignore-errors', '--prefer-ffmpeg', '--no-mtime', '--add-metadata', '--write-all-thumbnails', '--extract-audio', '--format', 'bestaudio', '--audio-format', 'mp3', '--audio-quality', '0', '--embed-thumbnail', '--restrict-filenames', '--cache-dir=/scripts/tools/youtube-dl/.cache', '-o', '/scripts/tools/youtube-dl/.music-folder/%(title)s-%(id)s.%(ext)s']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://youtu.be/vXDdIp5LxLY', '-v']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.06.16.1
[debug] Python version 3.5.2 (CPython) - Linux-4.10.0-32-generic-x86_64-with-Ubuntu-16.04-xenial
[debug] exe versions: avconv 2.8.15, avprobe 2.8.15, ffmpeg 2.8.15, ffprobe 2.8.15
[debug] Proxy map: {}
[youtube] vXDdIp5LxLY: Downloading webpage
[youtube] vXDdIp5LxLY: Downloading thumbnail 0 ...
[youtube] vXDdIp5LxLY: Writing thumbnail 0 to: /scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY_0.jpg
[youtube] vXDdIp5LxLY: Downloading thumbnail 1 ...
[youtube] vXDdIp5LxLY: Writing thumbnail 1 to: /scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY_1.jpg
[youtube] vXDdIp5LxLY: Downloading thumbnail 2 ...
[youtube] vXDdIp5LxLY: Writing thumbnail 2 to: /scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY_2.jpg
[youtube] vXDdIp5LxLY: Downloading thumbnail 3 ...
[youtube] vXDdIp5LxLY: Writing thumbnail 3 to: /scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY_3.jpg
[youtube] vXDdIp5LxLY: Downloading thumbnail 4 ...
[youtube] vXDdIp5LxLY: Writing thumbnail 4 to: /scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY_4.webp
[debug] Invoking downloader on 'https://r1---sn-t0a7sn7d.googlevideo.com/videoplayback?expire=1594253341&ei=vQsGX9O0H_Dnhwacu6SwDA&ip=149.56.240.116&id=o-AGVfsCKujrToB5omxijFBuokRUCLyWA2-EL4f7NJyT_k&itag=251&source=youtube&requiressl=yes&mh=EX&mm=31%2C26&mn=sn-t0a7sn7d%2Csn-25ge7nsk&ms=au%2Conr&mv=m&mvi=1&pl=20&initcwndbps=360000&vprv=1&mime=audio%2Fwebm&gir=yes&clen=2241111&dur=138.701&lmt=1572877652635863&mt=1594231659&fvip=1&keepalive=yes&c=WEB&txp=1301222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAPjJRFqQeiGlZ4JnwW3xQX0GQYwYPU-Xk6uJMykuL2NgAiEAoMDPBEmu0-HrhzvxO6vTpuXby0Mp7eNS8Perq5GSlo0%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgJU0o014GQ_j22E34zlTpB6oKkJdzHAkrLK0HUWtCpksCIBVgS_CygZjM9ZaWSeolmHIorYqzVGn1qa9iGTHGsPOE&ratebypass=yes'
[download] Destination: /scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.webm
[download] 100% of 2.14MiB in 00:00
[debug] ffmpeg command line: ffprobe -show_streams file:/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.webm
[ffmpeg] Destination: /scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.mp3
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i file:/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.webm -vn -acodec libmp3lame -q:a 0 file:/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.mp3
Deleting original file /scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.webm (pass -k to keep)
[ffmpeg] Adding metadata to '/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.mp3'
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i file:/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.mp3 -c copy -metadata artist=MrDeepSound -metadata 'title=Low Deep T - Beautiful Things In Life' -metadata 'description=One of my favorite tracks of all time...' -metadata 'comment=One of my favorite tracks of all time...' -metadata 'purl=https://www.youtube.com/watch?v=vXDdIp5LxLY' -metadata date=20141129 file:/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.temp.mp3
[ffmpeg] Adding thumbnail to "/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.mp3"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i file:/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.mp3 -i file:/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY_4.webp -c copy -map 0 -map 1 -metadata:s:v 'title="Album cover"' -metadata:s:v 'comment="Cover (Front)"' file:/scripts/tools/youtube-dl/.music-folder/Low_Deep_T_-_Beautiful_Things_In_Life-vXDdIp5LxLY.temp.mp3
ERROR: Conversion failed!
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/youtube_dl/YoutubeDL.py", line 2065, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/local/lib/python3.5/dist-packages/youtube_dl/postprocessor/embedthumbnail.py", line 51, in run
    self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options)
  File "/usr/local/lib/python3.5/dist-packages/youtube_dl/postprocessor/ffmpeg.py", line 235, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
youtube_dl.postprocessor.ffmpeg.FFmpegPostProcessorError: Conversion failed!

I am very certain my exact setup was embedding the thumbnails a year ago. So I have updated youtube-dl and have also installed python-pyxattr, and python-xattr. I have also installed youtube with pip3.

With the /etc/youtube-dl.conf configured as I have shown above, all I have to do is issue the following command in a script or on the command line.

youtube-dl https://youtu.be/vXDdIp5LxLY -v

Upvotes: 1

Views: 1660

Answers (1)

Constantine Kurbatov
Constantine Kurbatov

Reputation: 905

As was said by Marco Lucidi the reason is that the WEBP image format is not supported for the embedding.

To solve the problem locally, you may modify the following file in the youtube-dl source code to have embedding works (check the path):

$pip3 install --upgrade Pillow    
$sudo nano /usr/local/lib/python3.8/site-packages/youtube_dl/postprocessor/embedthumbnail.py

with the following code (insert it before the call that rises the exception) :

   # Add this code:
   if thumbnail_filename.endswith('webp'):
       from PIL import Image
       im = Image.open(thumbnail_filename).convert('RGB')
       thumbnail_filename  = thumbnail_filename[:-4]+'jpg' # replace filename with the proper extention
       im.save(thumbnail_filename, 'jpeg') # converts webp -> jpg           
       self._downloader.to_screen('[ffmpeg] ——> Converted thumbnail filename: "%s"' % thumbnail_filename)
   # Put the proposed code before this existing string (line 51 in my case):              
   self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options)

The Pillow library is used to convert images between various formats. I added this code to convert from WEBP that often is downloaded instead of JPG thumbnail.

Upvotes: 1

Related Questions