"Error: unpack requires a buffer of 4 bytes" when scanning m4a files suddenly

Tags: #<Tag:0x00007ff14a2dda00> #<Tag:0x00007ff14a2dd848> #<Tag:0x00007ff14a2dd618> #<Tag:0x00007ff14a2dd3e8>

EDIT: this seems to have stopped happening, not sure why…

I tried to scan some music and this happens, it seems to be limited to certain m4a files. The weird thing is that some or most of them have been scanned and tagged successfully before, I’m not sure what has changed to be honest.

Maybe it’s related to musicbee volume analysis or something?

Here is the log:

D: 21:55:12,769 tagger.__init__:202: Starting Picard from 'C:\\Program Files\\MusicBrainz Picard\\picard\\tagger.pyc'
D: 21:55:12,769 tagger.__init__:204: Platform: Windows-10-10.0.18362-SP0 CPython 3.7.2
D: 21:55:12,769 tagger.__init__:205: Versions: Picard 2.1.3, Python 3.7.2, PyQt 5.12, Qt 5.12.1, Mutagen 1.42.0, Discid discid 1.1.1, libdiscid 0.6.2, astrcmp Python, SSL OpenSSL 1.0.2k  26 Jan 2017
D: 21:55:12,769 tagger.__init__:206: Configuration file path: 'C:/Users/Forcen/AppData/Roaming/MusicBrainz/Picard.ini'
D: 21:55:12,769 tagger.__init__:208: User directory: 'C:\\Users\\Forcen\\AppData\\Local\\MusicBrainz\\Picard'
D: 21:55:12,785 i18n.setup_gettext:41: unsupported locale setting
D: 21:55:12,786 i18n.setup_gettext:71: Using locale 'en_US.cp1252'
D: 21:55:12,786 i18n.setup_gettext:73: Loading gettext translation, localedir='C:\\Program Files\\MusicBrainz Picard\\locale'
D: 21:55:12,787 i18n.setup_gettext:77: Loading gettext translation (picard-countries), localedir='C:\\Program Files\\MusicBrainz Picard\\locale'
D: 21:55:12,788 i18n.setup_gettext:84: [Errno 2] No translation file found for domain: 'picard-countries'
D: 21:55:12,788 i18n.setup_gettext:103: _ = <function setup_gettext.<locals>.<lambda> at 0x000001587F032D90>
D: 21:55:12,788 i18n.setup_gettext:104: N_ = <function <lambda> at 0x000001587EB491E0>
D: 21:55:12,788 i18n.setup_gettext:105: ngettext = <function setup_gettext.<locals>._ngettext at 0x000001587F18E510>
D: 21:55:12,788 i18n.setup_gettext:106: gettext_countries = <function setup_gettext.<locals>._gettext_countries at 0x000001587F18E598>
D: 21:55:12,788 i18n.setup_gettext:107: gettext_attributes = <function setup_gettext.<locals>._gettext_attributes at 0x000001587F18E620>
D: 21:55:12,815 webservice.set_cache:293: NetworkDiskCache dir: 'C:/Users/Forcen/AppData/Local/MusicBrainz/Picard/cache/picard/' size: 94315179 / 104857600
I: 21:55:12,816 plugin.load_plugindir:267: Plugin directory 'C:\\Program Files\\MusicBrainz Picard\\plugins' doesn't exist
D: 21:55:12,816 plugin.load_plugindir:292: Looking for plugins in directory 'C:\\Users\\Forcen\\AppData\\Local\\MusicBrainz\\Picard\\plugins', 2 names found
D: 21:55:12,819 plugin.load_plugin:347: Loading plugin 'Add Cluster As Release' version 0.7.3, compatible with API: 2.0
D: 21:55:12,821 plugin.load_plugin:347: Loading plugin 'Copy Cluster to Clipboard' version 1.0, compatible with API: 2.0
D: 21:55:13,471 tagger.main:878: Looking for Qt locale en_US in C:/Program Files/MusicBrainz Picard/PyQt5/Qt/translations
D: 21:55:13,487 browser.browser.start:69: Starting the browser integration (
D: 21:55:13,550 ui.mainwindow.auto_update_check:1140: Skipping start-up check for program updates.  Today: 2019-08-20, Last check: 2019-08-20 (Check interval: 7 days), Update level: 0 (stable)
D: 21:55:13,551 webservice.ratecontrol.get_delay_to_next_request:109: ('musicbrainz.org', 443): First request
D: 21:55:13,555 webservice.ratecontrol.increment_requests:134: ('musicbrainz.org', 443): Incrementing requests to: 1
D: 21:55:14,150 webservice.ratecontrol.decrement_requests:142: ('musicbrainz.org', 443): Decrementing requests to: 0
D: 21:55:14,151 webservice._handle_reply:411: Received reply for https://musicbrainz.org:443/ws/2/collection: HTTP 200 (OK) 
D: 21:55:14,152 webservice.ratecontrol._out_of_backoff:225: ('musicbrainz.org', 443): oobackoff; delay: 1000ms -> 1000ms; slow start; window size 1.000 -> 2.000
D: 21:55:20,307 ui.itemviews.dropMimeData:548: Drop target = None
D: 21:55:20,308 ui.itemviews.drop_urls:511: Dropped the URL: 'file:///K:/Music/The Bouncer _ Sion Barzahd _ 2000.m4a'
D: 21:55:20,309 tagger.add_files:451: Adding files [<File 'The Bouncer _ Sion Barzahd _ 2000.m4a'>]
D: 21:55:20,309 file._move:454: Moving <File 'The Bouncer _ Sion Barzahd _ 2000.m4a'> from None to <Cluster 'Unclustered Files'>
D: 21:55:20,310 formats.mp4._load:131: Loading file 'K:\\Music\\The Bouncer _ Sion Barzahd _ 2000.m4a'
E: 21:55:20,312 util.thread.run:56: Traceback (most recent call last):
  File "site-packages\mutagen\mp4\__init__.py", line 1073, in load
  File "site-packages\mutagen\mp4\__init__.py", line 343, in __init__
  File "site-packages\mutagen\mp4\__init__.py", line 363, in load
  File "site-packages\mutagen\mp4\__init__.py", line 595, in __parse_freeform
  File "site-packages\mutagen\_util.py", line 558, in <lambda>
struct.error: unpack requires a buffer of 4 bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "picard\util\thread.py", line 52, in run
  File "picard\file.py", line 118, in _load_check
  File "picard\formats\mp4.py", line 132, in _load
  File "site-packages\mutagen\_file.py", line 49, in __init__
  File "site-packages\mutagen\_util.py", line 140, in wrapper
  File "site-packages\mutagen\mp4\__init__.py", line 1077, in load
  File "site-packages\mutagen\_compat.py", line 86, in reraise
  File "site-packages\mutagen\mp4\__init__.py", line 1073, in load
  File "site-packages\mutagen\mp4\__init__.py", line 343, in __init__
  File "site-packages\mutagen\mp4\__init__.py", line 363, in load
  File "site-packages\mutagen\mp4\__init__.py", line 595, in __parse_freeform
  File "site-packages\mutagen\_util.py", line 558, in <lambda>
mutagen.mp4.MP4MetadataError: unpack requires a buffer of 4 bytes

D: 21:55:20,316 file.update:501: Updating file <File 'The Bouncer _ Sion Barzahd _ 2000.m4a'>

Here are the tags for the file from mediainfo:

Complete name               : K:\Music\The Bouncer _ Sion Barzahd _ 2000.m4a
Format                      : MPEG-4
Format profile              : Apple audio with iTunes info
Codec ID                    : M4A  (isom/iso2)
File size                   : 3.26 MiB
Duration                    : 3 min 30 s
Overall bit rate mode       : Constant
Overall bit rate            : 130 kb/s
Album                       : The Bouncer Original Video Game Soundtrack
Album/Performer             : Noriko Matsueda & Takahito Eguchi
Album/Performer/Sort        : Matsueda, Noriko & Eguchi, Takahito
Part/Position               : 1
Part/Total                  : 1
Track name                  : Sion Barzahd
Track name/Position         : 2
Track name/Total            : 21
Performer/Sorted by         : Matsueda, Noriko & Eguchi, Takahito
Description                 : The Bouncer / Sion Barzahd / 2000 / Noriko Matsueda 松枝賀子 / Takahito Eguchi 江口貴勅
Recorded date               : 2001-03-26
Writing application         : Lavf58.26.101
Cover                       : Yes
Comment                     : The Bouncer / Sion Barzahd / 2000 / Noriko Matsueda 松枝賀子 / Takahito Eguchi 江口貴勅
ASIN                        : B00005NGZI
MEDIA                       : CD
MusicBrainz Album Release C : US
SCRIPT                      : Latn
MusicBrainz Album Status    : official
CATALOGNUMBER               : TPCD 0204-2
BARCODE                     : 645573020422
LABEL                       : TOKYOPOP Soundtrax
MusicBrainz Release Track I : 3885b32c-f6c8-3907-83a9-6130264e16eb
MusicBrainz Album Id        : 3c61ef0c-26b2-4904-913c-297d82740abe
MusicBrainz Release Group I : 8ea3b0df-4c92-380c-bfcb-915b763e7913
Acoustid Id                 : ba1151df-2d49-4554-a249-c7cbd54f3837
MusicBrainz Track Id        : cbf1632f-cce4-4a6d-96e0-68955fd585b5
replaygain_track_gain       : -10.43 dB
replaygain_track_peak       : 1.082804

ID                          : 1
Format                      : AAC LC
Format/Info                 : Advanced Audio Codec Low Complexity
Codec ID                    : mp4a-40-2
Duration                    : 3 min 30 s
Bit rate mode               : Constant
Bit rate                    : 126 kb/s
Channel(s)                  : 2 channels
Channel layout              : L R
Sampling rate               : 44.1 kHz
Frame rate                  : 43.066 FPS (1024 SPF)
Compression mode            : Lossy
Stream size                 : 3.15 MiB (96%)
Default                     : Yes
Alternate group             : 1

EDIT: this seems to have stopped happening, not sure why…

See issue reported at

Given the example the saved files contain some invalid tag data, and Picard (or rather mutagen, the library Picard uses for tag handling) fails to read those.

The real question is how these bad tags came into the files. You also say that these tags had been written before. Was this with the same version of Picard, an earlier version or with a different tool?

Also the user in the issue report is using Musicbee, any chance you are also using Musicbee?

1 Like

Sorry for the late response but yes, I’m using musicbee. I’m getting the files using youtube-dl also. Tried re downloading a track and scanning it and that one works but the old one gets the error.

It I thought it might be the volume adjustment feature of MusicBee but i tried to do it on the new file and it still works in picard…