beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.87k stars 1.82k forks source link

Unreadable file *.m4a #4966

Closed beastyrabbit closed 1 year ago

beastyrabbit commented 1 year ago

Problem

Running this command in verbose (-vv) mode:

beet -vv import /home/media/Musik/AcDc/1983\ \ Flick\ of\ the\ Switch/
user configuration: /config/config.yaml
data directory: /config
plugin paths: 
lyrics: Disabling google source: no API key configured.
Sending event: pluginload
library database: /config/musiclibrary.blb
library directory: /home/media/Musik
Sending event: library_opened
Sending event: import_begin
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/01 - AcDc - Flick of the Switch - Rising Power.m4a
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/02 - AcDc - Flick of the Switch - This House Is on Fire.m4a
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/03 - AcDc - Flick of the Switch - Flick of the Switch.m4a
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/04 - AcDc - Flick of the Switch - Nervous Shakedown.m4a
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/05 - AcDc - Flick of the Switch - Landslide.m4a
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/06 - AcDc - Flick of the Switch - Guns for Hire.m4a
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/07 - AcDc - Flick of the Switch - Deep in the Hole.m4a
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/08 - AcDc - Flick of the Switch - Bedlam in Belgium.m4a
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/09 - AcDc - Flick of the Switch - Badlands.m4a
unreadable file: /home/media/Musik/AcDc/1983  Flick of the Switch/10 - AcDc - Flick of the Switch - Brain Shake.m4a
No files imported from /home/media/Musik/AcDc/1983  Flick of the Switch
Sending event: import
Sending event: cli_exit
root@02847d2cb0ab:/home/media/Musik# 

Led to this problem:

i just tried to import my LIB beet import /home/media/Musik

Here's a link to the music files that trigger the bug (if relevant): Had to zip it because m4a not allowed 01 - AcDc - Flick of the Switch - Rising Power.zip I got a lot more files if needed

Setup

My configuration (output of beet config) is:

lyrics:
    bing_lang_from: []
    auto: yes
    bing_client_secret: REDACTED
    bing_lang_to:
    google_API_key: REDACTED
    google_engine_ID: REDACTED
    genius_api_key: REDACTED
    fallback:
    force: no
    local: no
    sources:
    - google
    - musixmatch
    - genius
    - tekstowo

plugins: inline fetchart embedart convert scrub replaygain lastgenre chroma web bpm lyrics fromfilename plexupdate
directory: /home/media/Musik
library: /config/musiclibrary.blb
art_filename: albumart
threaded: yes
original_date: no
per_disc_numbering: no
convert:
    auto: no
    ffmpeg: /usr/bin/ffmpeg
    opts: -ab 320k -ac 2 -ar 48000
    max_bitrate: 320
    threads: 1
    hardlink: yes
    dest:
    pretend: no
    link: no
    format: mp3
    id3v23: inherit
    formats:
        aac:
            command: ffmpeg -i $source -y -vn -acodec aac -aq 1 $dest
            extension: m4a
        alac:
            command: ffmpeg -i $source -y -vn -acodec alac $dest
            extension: m4a
        flac: ffmpeg -i $source -y -vn -acodec flac $dest
        mp3: ffmpeg -i $source -y -vn -aq 2 $dest
        opus: ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest
        ogg: ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest
        wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
    tmpdir:
    quiet: no
    embed: yes

    paths: {}
    no_convert: ''
    never_convert_lossy_files: no
    copy_album_art: no
    album_art_maxwidth: 0
    delete_originals: no

paths:
    default: $albumartist/$album%aunique{}/$track - $title
    singleton: Non-Album/$artist - $title
    comp: Compilations/$album%aunique{}/$track - $title
    albumtype_soundtrack: Soundtracks/$album/$track $title

import:
    write: yes
    copy: no
    move: no
    hardlink: yes
    resume: yes
    incremental: yes
    incremental_skip_later: yes
    quiet: yes
    duplicate_action: merge
    quiet_fallback: skip
    timid: no
    log: /config/beet.log
lastgenre:
    auto: yes
    source: album
    whitelist: yes
    min_weight: 10
    count: 1
    fallback:
    canonical: no
    force: yes
    separator: ', '
    prefer_specific: no
    title_case: yes
embedart:
    auto: yes
    maxwidth: 0
    compare_threshold: 0
    ifempty: no
    remove_art_file: no
    quality: 0
fetchart:
    auto: yes
    minwidth: 0
    maxwidth: 0
    quality: 0
    max_filesize: 0
    enforce_ratio: no
    cautious: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    sources:
    - filesystem
    - coverart
    - itunes
    - amazon
    - albumart
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
    lastfm_key: REDACTED
    store_source: no
    high_resolution: no
    deinterlace: no
    cover_format:
replaygain:
    auto: no
    overwrite: no
    backend: command
    threads: 32
    parallel_on_import: no
    per_disc: no
    peak: 'true'
    targetlevel: 89
    r128: [Opus]
    r128_targetlevel: 84
    command: ''
    noclip: yes
scrub:
    auto: yes

replace:
    ^\.: _
    '[\x00-\x1f]': _
    '[<>:"\?\*\|]': _
    '[\xE8-\xEB]': e
    '[\xEC-\xEF]': i
    '[\xE2-\xE6]': a
    '[\xF2-\xF6]': o
    '[\xF8]': o
    \.$: _
    \s+$: ''
web:
    host: 0.0.0.0
    port: 8337
    cors: ''
    cors_supports_credentials: no
    reverse_proxy: no
    include_paths: no
    readonly: yes
plex:
    host: Plex-Media-Server
    port: 32400
    token: REDACTED
    library_name: Music
    secure: no
    ignore_cert_errors: no
chroma:
    auto: yes
acoustid:
    apikey: REDACTED
bpm:
    max_strokes: 3
    overwrite: yes
pathfields: {}
item_fields: {}
album_fields: {}
sampsyo commented 1 year ago

Hello! This file is not readable by Mutagen, the low-level library we use to interact with file metadata. Here's a complete traceback:

$ python3 -c 'import mutagen ; mutagen.File("t.m4a")'
Traceback (most recent call last):
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/mp4/__init__.py", line 1196, in load
    self.tags = self.MP4Tags(atoms, fileobj)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/mp4/__init__.py", line 341, in __init__
    self.load(*args, **kwargs)
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/mp4/__init__.py", line 361, in load
    info[0](self, atom, data)
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/mp4/__init__.py", line 598, in __parse_freeform
    length = cdata.uint_be(data[pos:pos + 4])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/_util.py", line 559, in <lambda>
    get_wrapper = lambda f: lambda *a, **k: f(*a, **k)[0]
                                            ^^^^^^^^^^
struct.error: unpack requires a buffer of 4 bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/_util.py", line 164, in wrapper_func
    return func(h, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/_file.py", line 302, in File
    return Kind(fileobj, filename=filething.filename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/_file.py", line 48, in __init__
    self.load(*args, **kwargs)
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/_util.py", line 156, in wrapper
    return func(self, h, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/mp4/__init__.py", line 1200, in load
    reraise(MP4MetadataError, err, sys.exc_info()[2])
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/_util.py", line 43, in reraise
    raise tp(value).with_traceback(tb)
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/mp4/__init__.py", line 1196, in load
    self.tags = self.MP4Tags(atoms, fileobj)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/mp4/__init__.py", line 341, in __init__
    self.load(*args, **kwargs)
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/mp4/__init__.py", line 361, in load
    info[0](self, atom, data)
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/mp4/__init__.py", line 598, in __parse_freeform
    length = cdata.uint_be(data[pos:pos + 4])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fabian/Library/Python/3.11/lib/python/site-packages/mutagen/_util.py", line 559, in <lambda>
    get_wrapper = lambda f: lambda *a, **k: f(*a, **k)[0]
                                            ^^^^^^^^^^
mutagen.mp4.MP4MetadataError: unpack requires a buffer of 4 bytes

Since this is an unhandled crash inside Mutagen, it might be useful to file a bug report with that project for further investigation (including this sample file that triggers the crash). https://github.com/quodlibet/mutagen/issues/new