track calculation is wrong #54

Closed
opened 2026-04-24 22:57:16 +02:00 by adam · 11 comments
Owner

Originally created by @mprivoro on GitHub (Oct 15, 2021).

(mp3 files) track number calculation looks wrong or not working.

mp3 track that shown by ffprob for example is like this

Input #0, mp3, from 'Azazel-02.mp3':
  Metadata:
    album           : Azazel
    artist          : Boris Akunin
    album_artist    : Boris Akunin
    genre           : Audiobook
    title           : Azazel-02
    track           : 02
    date            : 1998
  Duration: 00:11:30.16, start: 0.025057, bitrate: 192 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s
    Metadata:
      encoder         : LAME3.92 

but server crawler detects it like 1 and prints "Duplicate track number"

Described above is happening for 20% of my collection

Originally created by @mprivoro on GitHub (Oct 15, 2021). (mp3 files) track number calculation looks wrong or not working. mp3 track that shown by ffprob for example is like this ``` Input #0, mp3, from 'Azazel-02.mp3': Metadata: album : Azazel artist : Boris Akunin album_artist : Boris Akunin genre : Audiobook title : Azazel-02 track : 02 date : 1998 Duration: 00:11:30.16, start: 0.025057, bitrate: 192 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s Metadata: encoder : LAME3.92 ``` but server crawler detects it like 1 and prints "Duplicate track number" Described above is happening for 20% of my collection
adam closed this issue 2026-04-24 22:57:16 +02:00
Author
Owner

@mprivoro commented on GitHub (Oct 16, 2021):

upd.
running in docker, the latest one is taken

@mprivoro commented on GitHub (Oct 16, 2021): upd. running in docker, the latest one is taken
Author
Owner

@advplyr commented on GitHub (Oct 16, 2021):

When you go to the manage tracks page, what is it saying under the column "Track From Metadata"

image

You can also sort and press save on that page to remove the errors for now, but I'd like to continue improving the scanner so this is needed less often.

@advplyr commented on GitHub (Oct 16, 2021): When you go to the manage tracks page, what is it saying under the column "Track From Metadata" ![image](https://user-images.githubusercontent.com/67830747/137561273-8046ac27-44a9-4bac-a06b-6f32a15c970f.png) You can also sort and press save on that page to remove the errors for now, but I'd like to continue improving the scanner so this is needed less often.
Author
Owner

@mprivoro commented on GitHub (Oct 16, 2021):

image

@mprivoro commented on GitHub (Oct 16, 2021): ![image](https://user-images.githubusercontent.com/7849370/137575688-83f86647-a31e-4114-9812-e1939b97df3c.png)
Author
Owner

@mprivoro commented on GitHub (Oct 16, 2021):

You can also sort and press save on that page to remove the errors for now, but I'd like to continue improving the scanner so this is needed less often.

Yes, i know, great function, but i have quite a big collection...

@mprivoro commented on GitHub (Oct 16, 2021): > You can also sort and press save on that page to remove the errors for now, but I'd like to continue improving the scanner so this is needed less often. Yes, i know, great function, but i have quite a big collection...
Author
Owner

@mprivoro commented on GitHub (Oct 16, 2021):

I debuged a little bit audioFileScanner.js
looks like gathering the track number is OK, so might be wrong in DB update or any other internal procedure?

image

`
updateMetadata(data) {
if (!this.metadata) this.metadata = new AudioFileMetadata()

var dataMap = {
  format: data.format,
  duration: data.duration,
  size: data.size,
  bitRate: data.bit_rate || null,
  language: data.language,
  codec: data.codec || null,
  timeBase: data.time_base,
  channels: data.channels,
  channelLayout: data.channel_layout,
  chapters: data.chapters || [],
  embeddedCoverArt: data.embedded_cover_art || null
}

`
this one does not include title, track num and etc metadata info, may it be the source of my problem?

@mprivoro commented on GitHub (Oct 16, 2021): I debuged a little bit audioFileScanner.js looks like gathering the track number is OK, so might be wrong in DB update or any other internal procedure? ![image](https://user-images.githubusercontent.com/7849370/137580396-ae74dbbf-53a0-4312-8b56-8290c5345933.png) ` updateMetadata(data) { if (!this.metadata) this.metadata = new AudioFileMetadata() var dataMap = { format: data.format, duration: data.duration, size: data.size, bitRate: data.bit_rate || null, language: data.language, codec: data.codec || null, timeBase: data.time_base, channels: data.channels, channelLayout: data.channel_layout, chapters: data.chapters || [], embeddedCoverArt: data.embedded_cover_art || null } ` this one does not include title, track num and etc metadata info, may it be the source of my problem?
Author
Owner

@advplyr commented on GitHub (Oct 16, 2021):

I just pushed a patch that adds a button to the bottom of the edit tracks page. That button will call this function that only loops through the tracks and gets the relevant data.
You will need to enable experimental features to see the button.

image

This should help us debug.

Important note: the "re-scan" button in the edit pop-up is not going to update track numbers, track numbers are only set when the book is first added OR when audio files are added/removed. That is why you don't see track num in that object.

@advplyr commented on GitHub (Oct 16, 2021): I just pushed a patch that adds a button to the bottom of the edit tracks page. That button will call [this](https://github.com/advplyr/audiobookshelf/blob/master/server/utils/audioFileScanner.js#L237) function that only loops through the tracks and gets the relevant data. You will need to enable experimental features to see the button. ![image](https://user-images.githubusercontent.com/67830747/137588334-0a388168-a804-4224-b6d4-8d32f6af08b2.png) This should help us debug. Important note: the "re-scan" button in the edit pop-up is not going to update track numbers, track numbers are only set when the book is first added OR when audio files are added/removed. That is why you don't see track num in that object.
Author
Owner

@mprivoro commented on GitHub (Oct 16, 2021):

Here is the result

image

@mprivoro commented on GitHub (Oct 16, 2021): Here is the result ![image](https://user-images.githubusercontent.com/7849370/137589966-03f68ea0-3049-4109-aa6c-8ffee22c8a0e.png)
Author
Owner

@mprivoro commented on GitHub (Oct 16, 2021):

also it looks like clicking this button is not taking the all files into account

image

@mprivoro commented on GitHub (Oct 16, 2021): also it looks like clicking this button is not taking the all files into account ![image](https://user-images.githubusercontent.com/7849370/137590013-976afd70-30a3-4e5d-a1b2-7a8ca912371f.png)
Author
Owner

@advplyr commented on GitHub (Oct 16, 2021):

Yeah it is only looking at audio tracks, which would exclude audio files with errors or that you intentionally excluded.

Given those 2 results it looks like the scanner is working fine for your files.
When you added those audiobooks did you already have them in the directory when you pressed scan? Or did you move them into the directory after?
Have you moved any audio files in either of those 2 examples you shared?

The reason I ask is because there are only 2 times where the track number gets set. The first scan and when new audio files are added.

@advplyr commented on GitHub (Oct 16, 2021): Yeah it is only looking at audio tracks, which would exclude audio files with errors or that you intentionally excluded. Given those 2 results it looks like the scanner is working fine for your files. When you added those audiobooks did you already have them in the directory when you pressed scan? Or did you move them into the directory after? Have you moved any audio files in either of those 2 examples you shared? The reason I ask is because there are only 2 times where the track number gets set. The first scan and when new audio files are added.
Author
Owner

@mprivoro commented on GitHub (Oct 17, 2021):

Yah, something like that.
I saw that some track are not OK, so i went to the files and fixed them manually - tried to reindex to fix the issue...
now i see that once i'm removing the book from the system and then reindexing - everything is OK.

so it more looks like my misunderstanding the system's flows rather than bug.

i very appreciate your help and want to thank you on creating such system!

thank you!

@mprivoro commented on GitHub (Oct 17, 2021): Yah, something like that. I saw that some track are not OK, so i went to the files and fixed them manually - tried to reindex to fix the issue... now i see that once i'm removing the book from the system and then reindexing - everything is OK. so it more looks like my misunderstanding the system's flows rather than bug. i **very** appreciate your help and want to thank you on creating such system! thank you!
Author
Owner

@advplyr commented on GitHub (Oct 17, 2021):

I'm glad it is working okay now. I have been considering adding a feature that would allow you to fix the metadata on your files, so you don't have to open up your file system. Only reason I haven't yet actually is because it hasn't been requested yet.

@advplyr commented on GitHub (Oct 17, 2021): I'm glad it is working okay now. I have been considering adding a feature that would allow you to fix the metadata on your files, so you don't have to open up your file system. Only reason I haven't yet actually is because it hasn't been requested yet.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#54