Spotify-downloader: BUG: Mutagen ID3 No header error

Created on 28 Oct 2020  Β·  59Comments  Β·  Source: spotDL/spotify-downloader

When running the program i get an error from mutagen. I have looked around but could not find any related issues:

> $ spotdl https://open.spotify.com/track/398P1VKJo9gJQFZpY3vt8T?si=e_T_AWLySpGDWMMfV-zSBQ
Fetching Song... 95%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ– |ETA: 00:00, 0.09min/songTraceback (most recent call last): File "/home/sjoerdhilhorst/.local/bin/spotdl", line 8, in <module> sys.exit(console_entry_point()) File "/home/sjoerdhilhorst/.local/lib/python3.6/site-packages/spotdl/__main__.py", line 100, in console_entry_point downloader.download_single_song(song) File "/home/sjoerdhilhorst/.local/lib/python3.6/site-packages/spotdl/download/downloader.py", line 274, in download_single_song download_song(songObj, self.displayManager, self.downloadTracker) File "/home/sjoerdhilhorst/.local/lib/python3.6/site-packages/spotdl/download/downloader.py", line 170, in download_song audioFile = EasyID3(convertedFilePath) File "/home/sjoerdhilhorst/.local/lib/python3.6/site-packages/mutagen/easyid3.py", line 169, in __init__ self.load(filename) File "/home/sjoerdhilhorst/.local/lib/python3.6/site-packages/mutagen/_util.py", line 185, in wrapper return func(*args, **kwargs) File "/home/sjoerdhilhorst/.local/lib/python3.6/site-packages/mutagen/_util.py", line 156, in wrapper return func(self, h, *args, **kwargs) File "/home/sjoerdhilhorst/.local/lib/python3.6/site-packages/mutagen/id3/_file.py", line 152, in load self._header = ID3Header(fileobj) File "/home/sjoerdhilhorst/.local/lib/python3.6/site-packages/mutagen/_util.py", line 185, in wrapper return func(*args, **kwargs) File "/home/sjoerdhilhorst/.local/lib/python3.6/site-packages/mutagen/id3/_tags.py", line 59, in __init__ raise ID3NoHeaderError("%s: too small" % fn) mutagen.id3._util.ID3NoHeaderError: ./Yotto - Marisa.mp3: too small

Any ideas? i can't find much documentation on what the cause of this exception is

bug

Most helpful comment

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.98. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

All 59 comments

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.98. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

I tired downloading the same song, no issues here.

Try the following:

  1. pip install pip-autoremove
  2. pip-autoremove spotdl
  3. pip install spotdl
  4. spotdl https://open.spotify.com/track/398P1VKJo9gJQFZpY3vt8T?si=e_T_AWLySpGDWMMfV-zSBQ

Followed the steps, tried it for multiple songs. Still the same issue persists. A temp folder with mp4 file of the song is generated and an empy mp3 file is also instantiated.

And the progress bar goes till 100%?

It goes to 95%. When running the download again with the tracking file it goes to 100% without any errors but the mp3 file is still empty.

Could you open an issue at quodlibet/mutagen? They're more well versed with the library. It'd be much more simpler that me relaying info b/w you and them

Hello, just so you know, you're not alone. Just installed the latest release and I'm experiencing exactly the same issue (with an album) on Debian 10 Buster stable on a fresh new VPS.

Also experiencing this, have followed the reinstallation instructions that @Mikhail-Zex posted earlier.

Windows 10 Pro 64bit

Try this change and post the result please

https://github.com/quodlibet/mutagen/issues/502#issuecomment-719456377

@Mikhail-Zex The Issues is with FFMPEG not converting the .mp4 Downloaded with Pytube to Mp3 returning 0 byte File. So Mutagen see no Mp3 Header.

The question becomes why is ffmpeg not converting? We all run the same version for ffmpeg (stable build) and most users don't have this issue on win, mac, linux.

@kingy99 any idea what's triggering the ffmpeg error?

Make sure you're running 4.3.1 While Running Old Version of FFMPEG had issues with conversion till i install 4.3.1

command = 'ffmpeg -v quiet -y -i "%s" -acodec libmp3lame -abr true -af "apad=pad_dur=2, dynaudnorm, loudnorm=I=-17" "%s"' This code might not be supported by some versions of ffmpeg

@Mikhail-Zex

Well, there is no dynaudnorm,
And I am running the latest version from the official build page. It works fine for me and most others but some have issues.

It definitely isn't related to the ffmpeg version since this works for the base build of ffmpeg from v4 onwards

@kingy99

It's definitely not mutagen. When i had issues with old ffmpeg version the only thing i did to fix it is to Update the version of Ffpeg

Change the ffmpeg log-level to debug or error to check what goes wrong

@Silverarmor @SjoerdHilhorst @pianographe

could you guys grab a generic .mp4 file and run this command:

ffmpeg -v debug -y -i "$input.mp4" -acodec libmp3lame -abr true -af "apad=pad_dur=2, loudnorm=I=-17 "output.mp3"

where the input file is any mp4 file and the output file is $randomName.mp3

https://hastebin.com/ubexalezeb.yaml

This paste ommits a bunch of lines similar to

[mov,mp4,m4a,3gp,3g2,mj2 @ 0000024f4aed9f80] stts: 63734671 ctts: 1001, ctts_index: 63671, ctts_count: 63678

https://hastebin.com/ubexalezeb.yaml

This paste ommits a bunch of lines similar to

[mov,mp4,m4a,3gp,3g2,mj2 @ 0000024f4aed9f80] stts: 63734671 ctts: 1001, ctts_index: 63671, ctts_count: 63678

What was the command you ran? There's no output file specified acc to the log.

I ran ffmpeg -v debug -y -i "TPO.mp4" -acodec libmp3lame -abr true -af "apad=pad_dur=2, loudnorm=I=-17 "output.mp3"
Where my file name was TOP.mp4. There was a massive stream of text/data that filled my screen, which I was unable to upload (due to size) to any paste software, and it had even sent the ran command out of the cmd window.

There is a noice shortcut to bypass taht problem.

Run ffmpeg -v error-y -i "TPO.mp4" -acodec libmp3lame -abr true -af "apad=pad_dur=2, loudnorm=I=-17 "output.mp3" 2> log.txt, Pass on the log.txt file.

There is a noice shortcut to bypass taht problem.

Run ffmpeg -v error-y -i "TPO.mp4" -acodec libmp3lame -abr true -af "apad=pad_dur=2, loudnorm=I=-17 "output.mp3" 2> log.txt, Pass on the log.txt file.

Invalid loglevel "error-y". Possible levels are numbers or:
"quiet"
"panic"
"fatal"
"error"
"warning"
"info"
"verbose"
"debug"
"trace"

I tried running
ffmpeg -v debug -i "TPO.mp4" -acodec libmp3lame -abr true -af "apad=pad_dur=2, loudnorm=I=-17 "output.mp3" 2> log.txt

but have not got a log file.

just realised it was a 40 minute file I was testing on. Will try on a shorter one soon.

There is a noice shortcut to bypass taht problem.
Run ffmpeg -v error-y -i "TPO.mp4" -acodec libmp3lame -abr true -af "apad=pad_dur=2, loudnorm=I=-17 "output.mp3" 2> log.txt, Pass on the log.txt file.

Invalid loglevel "error-y". Possible levels are numbers or:
"quiet"
"panic"
"fatal"
"error"
"warning"
"info"
"verbose"
"debug"
"trace"

I tried running
ffmpeg -v debug -i "TPO.mp4" -acodec libmp3lame -abr true -af "apad=pad_dur=2, loudnorm=I=-17 "output.mp3" 2> log.txt

but have not got a log file.

just realised it was a 40 minute file I was testing on. Will try on a shorter one soon.

Run it os PS, not CMD, it works. Just checked.

$ ffmpeg -v debug -y -i "/home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4" -acodec libmp3lame -abr true -af "apad=pad_dur=2, dynaudnorm, loudnorm=I=-17" "./Fritz Kalkbrenner - Ride1.mp3"
ffmpeg version n4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  configuration: --prefix= --prefix=/usr --disable-debug --disable-doc --disable-static --enable-avisynth --enable-cuda --enable-cuvid --enable-libdrm --enable-ffplay --enable-gnutls --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopus --enable-libpulse --enable-sdl2 --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-nonfree --enable-nvenc --enable-omx --enable-openal --enable-opencl --enable-runtime-cpudetect --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-xlib
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-i' ... matched as input url with argument '/home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'libmp3lame'.
Reading option '-abr' ... matched as AVOption 'abr' with argument 'true'.
Reading option '-af' ... matched as option 'af' (set audio filters) with argument 'apad=pad_dur=2, dynaudnorm, loudnorm=I=-17'.
Reading option './Fritz Kalkbrenner - Ride1.mp3' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url /home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4.
Successfully parsed a group of options.
Opening an input file: /home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4.
[NULL @ 0x55e5ba63d080] Opening '/home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4' for reading
[file @ 0x55e5ba63db80] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e5ba63d080] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e5ba63d080] ISO: File Type Major Brand: dash
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e5ba63d080] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e5ba63d080] found sidx time -9223372036854775808, using it for pts
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e5ba63d080] Before avformat_find_stream_info() pos: 2648 bytes read:32768 seeks:0 nb_streams:1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e5ba63d080] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e5ba63d080] After avformat_find_stream_info() pos: 3012 bytes read:32768 seeks:0 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6mp41
    creation_time   : 2018-03-14T19:17:50.000000Z
  Duration: 00:07:16.30, start: 0.000000, bitrate: 127 kb/s
    Stream #0:0(und), 1, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 1 kb/s (default)
    Metadata:
      creation_time   : 2018-03-14T19:17:50.000000Z
      handler_name    : SoundHandler
Successfully opened the file.
Parsing a group of options: output url ./Fritz Kalkbrenner - Ride1.mp3.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument libmp3lame.
Applying option af (set audio filters) with argument apad=pad_dur=2, dynaudnorm, loudnorm=I=-17.
Successfully parsed a group of options.
Opening an output file: ./Fritz Kalkbrenner - Ride1.mp3.
[file @ 0x55e5ba6576c0] Setting default whitelist 'file,crypto'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
detected 8 logical cores
[Parsed_apad_0 @ 0x55e5ba73c0c0] Setting 'pad_dur' to value '2'
[Parsed_apad_0 @ 0x55e5ba73c0c0] Option 'pad_dur' not found
[AVFilterGraph @ 0x55e5ba666a40] Error initializing filter 'apad' with args 'pad_dur=2'
Error reinitializing filters!
Failed to inject frame into filter network: Option not found
Error while processing the decoded data for stream #0:0
[AVIOContext @ 0x55e5ba651ac0] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x55e5ba646040] Statistics: 32768 bytes read, 0 seeks
Conversion failed!

removed apad=pad_dur=2 and the conversion worked

Ok, thanks for the heads up, I'll check if it can be removed

apad=pad_dur=2 adds 2 seconds at the end as normalization sometimes 'cuts out' the last 2-3 seconds of the song (especially Edm songs)

@SjoerdHilhorst, try removing dynaudnorm instead. Please post the output here.

I ran this command also without any errors
$ ffmpeg -v debug -y -i "/home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4" -acodec libmp3lame -abr true -af "dynaudnorm, loudnorm=I=-17" "./Fritz Kalkbrenner - Ride1.mp3"

See, dynaudnorm should not be there it deadens the music. Try running it without dynaudnorm. That would be a great help.

oh damn, completely misread it and ran the wrong command, here is the right one. It returns the same error

$ ffmpeg -v debug -y -i "/home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4" -acodec libmp3lame -abr true -af "apad=pad_dur=2, loudnorm=I=-17" "./Fritz Kalkbrenner - Ride1.mp3"
ffmpeg version n4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  configuration: --prefix= --prefix=/usr --disable-debug --disable-doc --disable-static --enable-avisynth --enable-cuda --enable-cuvid --enable-libdrm --enable-ffplay --enable-gnutls --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopus --enable-libpulse --enable-sdl2 --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-nonfree --enable-nvenc --enable-omx --enable-openal --enable-opencl --enable-runtime-cpudetect --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-xlib
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-i' ... matched as input url with argument '/home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'libmp3lame'.
Reading option '-abr' ... matched as AVOption 'abr' with argument 'true'.
Reading option '-af' ... matched as option 'af' (set audio filters) with argument 'apad=pad_dur=2, loudnorm=I=-17'.
Reading option './Fritz Kalkbrenner - Ride1.mp3' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url /home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4.
Successfully parsed a group of options.
Opening an input file: /home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4.
[NULL @ 0x5566018d8080] Opening '/home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4' for reading
[file @ 0x5566018d8b80] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5566018d8080] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5566018d8080] ISO: File Type Major Brand: dash
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5566018d8080] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5566018d8080] found sidx time -9223372036854775808, using it for pts
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5566018d8080] Before avformat_find_stream_info() pos: 2648 bytes read:32768 seeks:0 nb_streams:1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5566018d8080] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5566018d8080] After avformat_find_stream_info() pos: 3012 bytes read:32768 seeks:0 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/sjoerdhilhorst/Documents/persoonlijk/songs/./Temp/Fritz Kalkbrenner - Ride.mp4':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6mp41
    creation_time   : 2018-03-14T19:17:50.000000Z
  Duration: 00:07:16.30, start: 0.000000, bitrate: 127 kb/s
    Stream #0:0(und), 1, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 1 kb/s (default)
    Metadata:
      creation_time   : 2018-03-14T19:17:50.000000Z
      handler_name    : SoundHandler
Successfully opened the file.
Parsing a group of options: output url ./Fritz Kalkbrenner - Ride1.mp3.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument libmp3lame.
Applying option af (set audio filters) with argument apad=pad_dur=2, loudnorm=I=-17.
Successfully parsed a group of options.
Opening an output file: ./Fritz Kalkbrenner - Ride1.mp3.
[file @ 0x5566018f26c0] Setting default whitelist 'file,crypto'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
detected 8 logical cores
[Parsed_apad_0 @ 0x556601902d00] Setting 'pad_dur' to value '2'
[Parsed_apad_0 @ 0x556601902d00] Option 'pad_dur' not found
[AVFilterGraph @ 0x5566018eea00] Error initializing filter 'apad' with args 'pad_dur=2'
Error reinitializing filters!
Failed to inject frame into filter network: Option not found
Error while processing the decoded data for stream #0:0
[AVIOContext @ 0x5566018ecac0] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x5566018e1040] Statistics: 32768 bytes read, 0 seeks
Conversion failed!

@Mikhail-Zex I have resolved this issue by uninstalling ffmpeg, and reinstalling & re-adding to path.

To others, ensure you are getting ffmpeg from https://www.gyan.dev/ffmpeg/builds/, not ffmpeg.org

EDIT: to clarify, I no longer have this issue, and can download songs flawlessly.

Tnx for the update. Do ya wanna help on spotDL dev?

@SjoerdHilhorst could you try what @Silverarmor suggested

Tnx for the update. Do ya wanna help on spotDL dev?

@Mikhail-Zex If you could elaborate?

Join the dev team, code occasionally, t reply to issues kinda thing.

Yes I'd be happy to help out where I can. I've been using spotDL for ages and am happy to give back.

I'll send you a invite by evening

I currently just use this command in downloader.py
command = 'ffmpeg -v quiet -y -i "%s" -acodec libmp3lame -abr true -af loudnorm=I=-17 "%s"'
and works. Any reasons this wouldn't be optimal, otherwise will just keep using this and it's fine

Try a couple of edm songs, is the ends don't get lopped off, open a PR.

I'll send you a invite by evening

@Mikhail-Zex πŸ‘€

You didn't get it?

Did not receive anything. Where was it supposed to come to? @Mikhail-Zex

@Mikhail-Zex

  1. I think this issue can be closed, seems everyone has been resolved
  2. still awaiting an invite/similar for helping on dev haha

Did not receive anything. Where was it supposed to come to? @Mikhail-Zex

Actually check again. It shows that the invite has been sent. I'm not sure where you'll find it. I think you'll see it under notifications and also in your email. I deleted your old invite and sent ya a new one.

@Mikhail-Zex Received.
Reminder to unpin this issue :)

So I'm confused. What was the solution? I am getting the issue.

Here is my output. At least I think it's the same issue.

spotdl https://open.spotify.com/track/08phoHar5Ns28HdeKUkTj6?si=rT8TpuuFRuGQ1-0w52I3Iw
Fetching Song...                                                                                                                                                                                  
Searching for: ε¦–η²ΎεΈεœ‹ - 濫觴永遠
 95%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Š        |ETA: 00:00, 0.03min/songTraceback (most recent call last):
  File "/home/zarafat/.local/bin/spotdl", line 10, in <module>
    sys.exit(console_entry_point())
  File "/home/zarafat/.local/lib/python3.7/site-packages/spotdl/__main__.py", line 96, in console_entry_point
    downloader.download_single_song(song)
  File "/home/zarafat/.local/lib/python3.7/site-packages/spotdl/download/downloader.py", line 74, in download_single_song
    self._download_asynchronously([songObj])
  File "/home/zarafat/.local/lib/python3.7/site-packages/spotdl/download/downloader.py", line 355, in _download_asynchronously
    self.loop.run_until_complete(asyncio.gather(*tasks))
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/home/zarafat/.local/lib/python3.7/site-packages/spotdl/download/downloader.py", line 350, in _pool_download
    return await self.download_song(song_obj)
  File "/home/zarafat/.local/lib/python3.7/site-packages/spotdl/download/downloader.py", line 247, in download_song
    self.set_id3_data(convertedFilePath, songObj)
  File "/home/zarafat/.local/lib/python3.7/site-packages/spotdl/download/downloader.py", line 264, in set_id3_data
    audioFile = EasyID3(convertedFilePath)
  File "/home/zarafat/.local/lib/python3.7/site-packages/mutagen/easyid3.py", line 169, in __init__
    self.load(filename)
  File "/home/zarafat/.local/lib/python3.7/site-packages/mutagen/_util.py", line 185, in wrapper
    return func(*args, **kwargs)
  File "/home/zarafat/.local/lib/python3.7/site-packages/mutagen/_util.py", line 156, in wrapper
    return func(self, h, *args, **kwargs)
  File "/home/zarafat/.local/lib/python3.7/site-packages/mutagen/id3/_file.py", line 152, in load
    self._header = ID3Header(fileobj)
  File "/home/zarafat/.local/lib/python3.7/site-packages/mutagen/_util.py", line 185, in wrapper
    return func(*args, **kwargs)
  File "/home/zarafat/.local/lib/python3.7/site-packages/mutagen/id3/_tags.py", line 59, in __init__
    raise ID3NoHeaderError("%s: too small" % fn)
mutagen.id3._util.ID3NoHeaderError: ε¦–η²ΎεΈεœ‹ - 濫觴永遠.mp3: too small
Exception ignored in: <function tqdm.__del__ at 0x7f158bdc1268>
Traceback (most recent call last):
  File "/home/zarafat/.local/lib/python3.7/site-packages/tqdm/std.py", line 1134, in __del__
  File "/home/zarafat/.local/lib/python3.7/site-packages/tqdm/std.py", line 1281, in close
  File "/home/zarafat/.local/lib/python3.7/site-packages/tqdm/std.py", line 1467, in display
  File "/home/zarafat/.local/lib/python3.7/site-packages/tqdm/std.py", line 1137, in __repr__
  File "/home/zarafat/.local/lib/python3.7/site-packages/spotdl/download/progressHandlers.py", line 23, in format_dict
  File "/home/zarafat/.local/lib/python3.7/site-packages/tqdm/std.py", line 1424, in format_dict
TypeError: cannot unpack non-iterable NoneType object

@RustyRaptor Try cleanly re-install spotDL:

Try the following:

  1. pip install pip-autoremove
  2. pip-autoremove spotdl
  3. pip cache purge
  4. pip install spotdl

Same problem here. I followed the steps to "cleanly re-install spotDL", and it didn't help.

$ spotdl https://open.spotify.com/track/0VjIjW4GlUZAMYd2vXMi3b?si=1stnMF5GSdClnIEARnJiiQ
Fetching Song...
Searching for: The Weeknd - Blinding Lights
 95%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‹          |ETA: 00:00, 0.07min/songTraceback (most recent call last):
  File "/usr/local/bin/spotdl", line 8, in <module>
    sys.exit(console_entry_point())
  File "/usr/local/lib/python3.7/dist-packages/spotdl/__main__.py", line 96, in console_entry_point
    downloader.download_single_song(song)
  File "/usr/local/lib/python3.7/dist-packages/spotdl/download/downloader.py", line 74, in download_single_song
    self._download_asynchronously([songObj])
  File "/usr/local/lib/python3.7/dist-packages/spotdl/download/downloader.py", line 355, in _download_asynchronously
    self.loop.run_until_complete(asyncio.gather(*tasks))
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.7/dist-packages/spotdl/download/downloader.py", line 350, in _pool_download
    return await self.download_song(song_obj)
  File "/usr/local/lib/python3.7/dist-packages/spotdl/download/downloader.py", line 247, in download_song
    self.set_id3_data(convertedFilePath, songObj)
  File "/usr/local/lib/python3.7/dist-packages/spotdl/download/downloader.py", line 264, in set_id3_data
    audioFile = EasyID3(convertedFilePath)
  File "/usr/local/lib/python3.7/dist-packages/mutagen/easyid3.py", line 169, in __init__
    self.load(filename)
  File "/usr/local/lib/python3.7/dist-packages/mutagen/_util.py", line 185, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mutagen/_util.py", line 156, in wrapper
    return func(self, h, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mutagen/id3/_file.py", line 152, in load
    self._header = ID3Header(fileobj)
  File "/usr/local/lib/python3.7/dist-packages/mutagen/_util.py", line 185, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mutagen/id3/_tags.py", line 59, in __init__
    raise ID3NoHeaderError("%s: too small" % fn)
mutagen.id3._util.ID3NoHeaderError: The Weeknd - Blinding Lights.mp3: too small
Exception ignored in: <function tqdm.__del__ at 0x75787db0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/tqdm/std.py", line 1134, in __del__
  File "/usr/local/lib/python3.7/dist-packages/tqdm/std.py", line 1281, in close
  File "/usr/local/lib/python3.7/dist-packages/tqdm/std.py", line 1467, in display
  File "/usr/local/lib/python3.7/dist-packages/tqdm/std.py", line 1137, in __repr__
  File "/usr/local/lib/python3.7/dist-packages/spotdl/download/progressHandlers.py", line 23, in format_dict
  File "/usr/local/lib/python3.7/dist-packages/tqdm/std.py", line 1424, in format_dict
TypeError: cannot unpack non-iterable NoneType object 

@Silverarmor above says that we should get ffmpeg from the gyan.dev website, but that website is only for Windows. I'm running Raspian Linux on a Raspberry Pi.

@mikeblas
This error's really old. Join our discord and reach out there and we can talk more
Discord Server

What version of FFmpeg do you have? - Do you have the full build & latest?
Can you completely reinstall Python? - This solved the issue for some.

This error's really old.

Not sure I follow -- seems like it's being pretty consistently reported; many dupes to this item, and a similar report just 3 days ago.

Can you completely reinstall Python?

Is that a joke?

What version of FFmpeg do you have

$ ffmpeg -v
ffmpeg version 4.1.6-1~deb10u1+rpt1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Raspbian 8.3.0-6+rpi1)

No developer has been able to reproduce this error in recent versions of spotDL.

  • Try again to uninstall spotDL & all dependencies, then install with --no-cache-dir flag
  • Reinstall python - Something is clearly not working for you, since it works for the majority of other users.

I'm not the only person with this problem -- there are several reports in this issue, and several issues related to this one here.

Looking into the code around this code path, I think there are a couple of identifiable bugs that the team should consider addressing.

Around line 239 of downloader.py, we find this loop:

        #! Wait till converted file is actually created
        while True:
            if convertedFilePath.is_file():
                break

This loop will take 100% CPU while waiting for the file to be created. At least, it should sleep between iterations so CPU resources are available for the converter process -- or anything else the system is trying to run. Maybe there's a way to asynchronously await the arrival of the file.

But the other problem is that this loop releases when the file is created, not when it's completely written. I suspect the issue that your users are encountering are caused by a race condition where the file becomes visible, isn't completely written or flushed, but the spotDL tries to run the media converter on the file.

Just previous to this code, we find:

_ = await process.communicate()

and I'm not sure that works as intended, either. The call that creates the process doesn't set up stdin or stdout pipes, so I don't think there's any communicate() objects to await.

Reviewing the code in download.py also reveals a failure to check returns codes from the spawned ffmpeg process, and that's the root cause of the problem I've encountered. If ffmpeg fails for any reason, the spotDL code will keep on working. If the output file isn't written, it ends up hanging with 100% CPU usage due the loop I quoted above.

For me, the issue is that I've got ffmpeg version 7:4.1.6-1 installed. This is the newest official version for the Raspberry Pi:

$ sudo apt install ffmpeg
Reading package lists... Done
Building dependency tree
Reading state information... Done
ffmpeg is already the newest version (7:4.1.6-1~deb10u1+rpt1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

However, that version doesn't support the pad_dur option for the apad filter. spotDL passes this filter in the chian (as apad=pad_dur=2). ffmpeg fails, that failure isn't detected; ffmpeg writes a zero-byte output file, spotDL doesn't care to check, and crashes.

Getting a newer version of ffmpeg from snap exchanges this problem for another issue:

$ sudo snap install ffmpeg --classic
2021-01-25T15:54:27-08:00 INFO Waiting for restart...
ffmpeg N-76538-gb83c849 from Snapcrafters installed
Channel latest/stable for ffmpeg is closed; temporarily forwarding to stable.

because that version doesn't support the -abr option. I'll hve to find a way to get a version compatible with spotDL.

Until then, a raw Python stack dump is pretty harrowing for most users. Maybe the spotDL developers will consider any of these suggestions to improve matters for their users:

  • Document the required version of ffmpeg as 4.2 or newer (when pad_dur support was added)
  • Check the ffmpeg version at startup; if older, omit the pad_dur parameter; perhaps with a warning message
  • add code that checks the process.returncode in download.py to see if the spawned process failed or worked; if it fails, do something sensible instead of trying to process a broken output file
  • catch the piped output from the process to develop a clear error message. ffmpeg shows the user an actionable error message
  • add a --debug option to the script to share more output

Reinstalling Python, as recommended above, won't fix this issue.

Thanks @mikeblas for the great input. I think that we can apply your suggestions, but that can take some time.

The await process.communicate() waits for the process to finish, it doesn't matter that the streams are not piped, this code doesn't care about them as the output is assigned to _. The only purpose of this code is to hold the execution until the process finish. The communicate() method is better than wait() as the later deadlocks when streams are piped. I prefer to always use communicate() to avoid weird problems in the future if someone will pipe any stream.
The while loop, however, is weird. I've also got bitten by it - when ffmpeg didn't create a file for any reason, the application got stuck. I'm pretty sure we shouldn't enter this part if ffmpeg exits with non-zero code.

I don't know anything about ffmpeg, but your suggestion to adjust the pad_dur parameter makes sense - I'll let other folks, who know ffmpeg better decide here.

I like the idea of adding --debug switch, as it may be very useful in the future.

cc: @spotDL/contributors, @spotDL/joining-developers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MikhailZex picture MikhailZex  Β·  5Comments

linusg picture linusg  Β·  6Comments

michalfalat picture michalfalat  Β·  3Comments

iateadonut picture iateadonut  Β·  4Comments

marinabar picture marinabar  Β·  4Comments