LMS-Community / slimserver

Server for Squeezebox and compatible players. This server is also called Lyrion Music Server.
https://lyrion.org
Other
1.2k stars 296 forks source link

Audio::Scan::scan (64) Warning: Error: Unable to read at least 16 bytes from file (only read 8). #883

Closed jtbr closed 1 year ago

jtbr commented 1 year ago

The above error appears in scanner.log for hundreds (thousands?) of my files. They all appear to be m4a files (I also have mp3 and a few flac files in my library). Although I've seen discussions of similar errors, they seem unrelated to what I'm seeing.

E.g:

 [23-04-17 13:29:46.9960] Slim::Utils::Scanner::Local::changed (975) Handling changed audio track file:///data/Music/Electronic,%20Dance%20and%20Chill/Zmeyev%20-%2001-Mellow%20Vibes.m4a
 [23-04-17 13:29:46.9994] Slim::Schema::updateOrCreateBase (1840) Merging entry for file:///data/Music/Electronic,%20Dance%20and%20Chill/Zmeyev%20-%2001-Mellow%20Vibes.m4a readTags is: [1]
 [23-04-17 13:29:46.9997] Slim::Music::Info::typeFromPath (1555) mp4 file type for /data/Music/Electronic, Dance and Chill/Zmeyev - 01-Mellow Vibes.m4a
 [23-04-17 13:29:47.0053] Audio::Scan::scan (64) Warning: Error: Unable to read at least 16 bytes from file (only read 8).
 [23-04-17 13:29:47.0056] Slim::Formats::readTags (275) Report for file:///data/Music/Electronic,%20Dance%20and%20Chill/Zmeyev%20-%2001-Mellow%20Vibes.m4a:
 [23-04-17 13:29:47.0058] Slim::Formats::readTags (332) . COMPOSER : Konstantin Baratashvili
 [23-04-17 13:29:47.0060] Slim::Formats::readTags (332) . ARTWORK : 141022
 [23-04-17 13:29:47.0061] Slim::Formats::readTags (332) . GENRE : Chill
 ...

Despite the error, the scanner appears to be able to recognize, read, and LMS can play the files. Nonetheless, it may be linked with some other problems I am seeing (like playback stopping and further tracks in the playlist not loading).

Many of my m4a files have tags that were written by Mp3tag, including the two which were updated here (by Mp3tag v3.19 [Jan 27 2023]); that may be connected. But my understanding is that this app is known for producing good tags. The LMS is version 8.3.1. I am happy to attach one of the m4a files referenced, or a more complete log if I find a way to.

jtbr commented 1 year ago

attachments

m4afile.zip

scanner-unable_to_read_at_least_16_bytes_from_file.log

michaelherger commented 1 year ago

What Audio::Scan version is reported in Settings/Information? Did you post on forums.slimdevices.com, too? Some users might be able to identify the issue.

jtbr commented 1 year ago

What Audio::Scan version is reported in Settings/Information? Did you post on forums.slimdevices.com, too? Some users might be able to identify the issue.

Version 1.05.

I did not. I guess I will now then :), but I hadn't found any relevant discussion there so far. New discussion is here

Logitech Media Server Version: 8.3.1 - 1676361197 @ Fri 17 Feb 2023 06:37:09 AM CET Hostname: bruserv Server IP Address: 192.168.10.9 Server HTTP Port Number: 9000 Operating system: Debian - EN - utf8 Platform Architecture: x86_64-linux Perl Version: 5.34.0 - x86_64-linux-gnu-thread-multi Audio::Scan: 1.05 IO::Socket::SSL: 2.074 Database Version: DBD::SQLite 1.58 (sqlite 3.22.0) Total Players Recognized: 4

jtbr commented 1 year ago

Upon further experimentation, it seems that re-writing the file (with the same contents) using ffmpeg resolves the error. This would appear to be a viable workaround.

ffmpeg -i input.m4a -movflags faststart -c copy output.m4a

So it seems there is some incompatibility between Mp3tag and LMS. As I don't seem to have any issues with other players, I suspect the issue may be on the LMS side.

Note that this does seem to affect playback, at least with the castbridge plugin (LMS to chromecast), and is also associated with the server log message:

Slim::Player::Squeezebox2::statHandler (156) Error: 9c:b6:d0:ec:8e:8f: Decoder does not support file format, code 0

jtbr commented 1 year ago

The issue is that offending files have an empty mdat atom at the end of the file. (Thanks to bpa for discovering this). Audio::Scan is checking for a minimum of 16 bytes in an atom, while this atom has only 8. A patch to Audio::Scan has been submitted: https://github.com/LMS-Community/Audio-Scan/pull/3

Such files also encounter a decoder error during playback on squeezelite and derivative players (eg castbridge), as described here: https://github.com/ralph-irving/squeezelite/issues/184

As the atom is useless, users can work around related issues by removing it using the above ffmpeg command.

Closing, as the error message is from an embedded project (Audio::Scan).