[Bug]: Wrong duration of MP3 file shown #2003

Closed
opened 2026-04-25 00:02:16 +02:00 by adam · 6 comments
Owner

Originally created by @GregX0 on GitHub (May 23, 2024).

What happened?

Hello, I saw that you had already smth similar in the bug #2689 but it seems not to be fully resolved. I experiencing a problem with some mp3 files in a book shown with a much higher duration as it should be. I checked the file and it shows the right duration in VLC.
image
image
Two other files do exactly the same thing, so the book is much longer as it is in reality.
This book have 3 Main parts and is always the first file of these main parts. It more or less seemes to show in one file the lenght of the whole Part and then the other files are fine.

What did you expect to happen?

To detected the duration correctly of an MP3

Steps to reproduce the issue

You might need that book

Audiobookshelf version

2.9.0

How are you running audiobookshelf?

Debian/PPA

What OS is your Audiobookshelf server hosted from?

Linux

If the issue is being seen in the UI, what browsers are you seeing the problem on?

Firefox

Logs

No response

Additional Notes

No response

Originally created by @GregX0 on GitHub (May 23, 2024). ### What happened? Hello, I saw that you had already smth similar in the bug #2689 but it seems not to be fully resolved. I experiencing a problem with some mp3 files in a book shown with a much higher duration as it should be. I checked the file and it shows the right duration in VLC. ![image](https://github.com/advplyr/audiobookshelf/assets/131011784/1f9d4bb6-4fd7-4070-aff5-c4a696e67796) ![image](https://github.com/advplyr/audiobookshelf/assets/131011784/35215f5e-ff66-4a5d-979d-a0c7e49d4b23) Two other files do exactly the same thing, so the book is much longer as it is in reality. This book have 3 Main parts and is always the first file of these main parts. It more or less seemes to show in one file the lenght of the whole Part and then the other files are fine. ### What did you expect to happen? To detected the duration correctly of an MP3 ### Steps to reproduce the issue You might need that book ### Audiobookshelf version 2.9.0 ### How are you running audiobookshelf? Debian/PPA ### What OS is your Audiobookshelf server hosted from? Linux ### If the issue is being seen in the UI, what browsers are you seeing the problem on? Firefox ### Logs _No response_ ### Additional Notes _No response_
adam added the bug label 2026-04-25 00:02:16 +02:00
adam closed this issue 2026-04-25 00:02:16 +02:00
Author
Owner

@nichwall commented on GitHub (May 23, 2024):

Can you get the ffprobe output for the file in question? The metadata is probably wrong.

Screenshot_20240523-081019.png

@nichwall commented on GitHub (May 23, 2024): Can you get the ffprobe output for the file in question? The metadata is probably wrong. ![Screenshot_20240523-081019.png](https://github.com/advplyr/audiobookshelf/assets/5686638/3d33f376-ead1-4fef-a32b-865ba6036d03)
Author
Owner

@GregX0 commented on GitHub (May 23, 2024):

Sure thing:

{
"programs": [],
"streams": [
{
"index": 0,
"codec_name": "mp3",
"codec_long_name": "MP3 (MPEG audio layer 3)",
"codec_type": "audio",
"codec_tag_string": "[0][0][0][0]",
"codec_tag": "0x0000",
"sample_fmt": "fltp",
"sample_rate": "44100",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"initial_padding": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/14112000",
"start_pts": 353600,
"start_time": "0.025057",
"duration_ts": 296302878720,
"duration": "20996.519184",
"bit_rate": "128000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0
},
"tags": {
"encoder": "LAME3.98r"
},
"side_data_list": [
{
"side_data_type": "Replay Gain"
}
]
},
{
"index": 1,
"codec_name": "mjpeg",
"codec_long_name": "Motion JPEG",
"profile": "Progressive",
"codec_type": "video",
"codec_tag_string": "[0][0][0][0]",
"codec_tag": "0x0000",
"width": 175,
"height": 175,
"coded_width": 175,
"coded_height": 175,
"closed_captions": 0,
"film_grain": 0,
"has_b_frames": 0,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "1:1",
"pix_fmt": "yuvj444p",
"level": -99,
"color_range": "pc",
"color_space": "bt470bg",
"chroma_location": "center",
"refs": 1,
"r_frame_rate": "90000/1",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 2255,
"start_time": "0.025056",
"duration_ts": 1889686727,
"duration": "20996.519189",
"bits_per_raw_sample": "8",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 1,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0
},
"tags": {
"comment": "Cover (front)"
}
}
],
"chapters": [],
"format": {
"filename": "/media/Hoerbuecher/Robert Jordan/Das Rad der Zeit/Robert Jordan - Das Rad der Zeit - 09 - Der Sturm bricht los/Teil 1.Das Rad der Zeit 9 - Der Sturm bricht los Teil 1001.mp3",
"nb_streams": 2,
"nb_programs": 0,
"format_name": "mp3",
"format_long_name": "MP2/3 (MPEG audio layer 2/3)",
"start_time": "0.025056",
"duration": "20996.519184",
"size": "9630206",
"bit_rate": "3669",
"probe_score": 51,
"tags": {
"album": "Das Rad der Zeit - 09- Der Sturm bricht los",
"artist": "Robert Jordan",
"comment": "Über das Gebiet der Zwei Flüsse bricht die Hölle herein: Trollocs, die brutalen Häscher des Dunklen Königs, erobern das Land. Zugleich hat eine fanatische Sekte ein Heer entsandt um den König, die Aes Sedai und alle Schattenfreunde zu vernichten. Eine verheerende Schlacht entbrennt, in der es nur noch eine Hoffnung gibt: Rand al'Thor, der Wiedergeborene Drache, und seine Gefährten müssen sich zwischen die Fronten begeben und gegen die finsteren Mächte in die Schlacht ziehen. Doch deren Herrschaft scheint sich zu festigen, als auch noch ein geheimnisvoller Mann auftaucht, der sich Schlächter nennt. Mit immer vernichtenderen Schlägen dringen die Feinde ins Land vor.",
"genre": "Fantasy",
"title": " Der Sturm bricht los",
"date": "2010"
}
}
}

Thank you for having a look

@GregX0 commented on GitHub (May 23, 2024): Sure thing: { "programs": [], "streams": [ { "index": 0, "codec_name": "mp3", "codec_long_name": "MP3 (MPEG audio layer 3)", "codec_type": "audio", "codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "sample_fmt": "fltp", "sample_rate": "44100", "channels": 2, "channel_layout": "stereo", "bits_per_sample": 0, "initial_padding": 0, "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/14112000", "start_pts": 353600, "start_time": "0.025057", "duration_ts": 296302878720, "duration": "20996.519184", "bit_rate": "128000", "disposition": { "default": 0, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "non_diegetic": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "encoder": "LAME3.98r" }, "side_data_list": [ { "side_data_type": "Replay Gain" } ] }, { "index": 1, "codec_name": "mjpeg", "codec_long_name": "Motion JPEG", "profile": "Progressive", "codec_type": "video", "codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "width": 175, "height": 175, "coded_width": 175, "coded_height": 175, "closed_captions": 0, "film_grain": 0, "has_b_frames": 0, "sample_aspect_ratio": "1:1", "display_aspect_ratio": "1:1", "pix_fmt": "yuvj444p", "level": -99, "color_range": "pc", "color_space": "bt470bg", "chroma_location": "center", "refs": 1, "r_frame_rate": "90000/1", "avg_frame_rate": "0/0", "time_base": "1/90000", "start_pts": 2255, "start_time": "0.025056", "duration_ts": 1889686727, "duration": "20996.519189", "bits_per_raw_sample": "8", "disposition": { "default": 0, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 1, "timed_thumbnails": 0, "non_diegetic": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "comment": "Cover (front)" } } ], "chapters": [], "format": { "filename": "/media/Hoerbuecher/Robert Jordan/Das Rad der Zeit/Robert Jordan - Das Rad der Zeit - 09 - Der Sturm bricht los/Teil 1.Das Rad der Zeit 9 - Der Sturm bricht los Teil 1001.mp3", "nb_streams": 2, "nb_programs": 0, "format_name": "mp3", "format_long_name": "MP2/3 (MPEG audio layer 2/3)", "start_time": "0.025056", "duration": "20996.519184", "size": "9630206", "bit_rate": "3669", "probe_score": 51, "tags": { "album": "Das Rad der Zeit - 09- Der Sturm bricht los", "artist": "Robert Jordan", "comment": "Über das Gebiet der Zwei Flüsse bricht die Hölle herein: Trollocs, die brutalen Häscher des Dunklen Königs, erobern das Land. Zugleich hat eine fanatische Sekte ein Heer entsandt um den König, die Aes Sedai und alle Schattenfreunde zu vernichten. Eine verheerende Schlacht entbrennt, in der es nur noch eine Hoffnung gibt: Rand al'Thor, der Wiedergeborene Drache, und seine Gefährten müssen sich zwischen die Fronten begeben und gegen die finsteren Mächte in die Schlacht ziehen. Doch deren Herrschaft scheint sich zu festigen, als auch noch ein geheimnisvoller Mann auftaucht, der sich Schlächter nennt. Mit immer vernichtenderen Schlägen dringen die Feinde ins Land vor.", "genre": "Fantasy", "title": " Der Sturm bricht los", "date": "2010" } } } Thank you for having a look
Author
Owner

@nichwall commented on GitHub (May 23, 2024):

Yeah, the file metadata is wrong so ABS shows the wrong number.

  "start_time": "0.025057",
  "duration_ts": 296302878720,
  "duration": "20996.519184",

20996 seconds is about 350 minutes, which is 5.8 hours.

@nichwall commented on GitHub (May 23, 2024): Yeah, the file metadata is wrong so ABS shows the wrong number. > "start_time": "0.025057", > "duration_ts": 296302878720, > "duration": "20996.519184", 20996 seconds is about 350 minutes, which is 5.8 hours.
Author
Owner

@GregX0 commented on GitHub (May 23, 2024):

ah sorry, then it is not a bug, sorry for bothering. I didn't notice that since windows show in the file info the time right. Do you maybe know how to fix the meta automatically.

Thanks for your help!!

@GregX0 commented on GitHub (May 23, 2024): ah sorry, then it is not a bug, sorry for bothering. I didn't notice that since windows show in the file info the time right. Do you maybe know how to fix the meta automatically. Thanks for your help!!
Author
Owner

@nichwall commented on GitHub (May 23, 2024):

Oh, that's weird if Windows is reporting it correctly. I know advplyr mentioned there might be a bug with ffprobe 6.1, so ABS is using 5.1 until it is shown to be a bug with ffprobe or not.

You could do something like ffmpeg -i input.mp3 -c copy output.mp3. That will copy the contents of the file without encoding, but rewrite the header.

If you're willing to share the files, I can take a look at them tonight. Either through the email on my GitHub profile or nyxholas on the ABS Discord work. It might be nice to see all 3 of the original files to see what differences there are between them.

@nichwall commented on GitHub (May 23, 2024): Oh, that's weird if Windows is reporting it correctly. I know advplyr mentioned there might be a bug with ffprobe 6.1, so ABS is using 5.1 until it is shown to be a bug with ffprobe or not. You could do something like `ffmpeg -i input.mp3 -c copy output.mp3`. That will copy the contents of the file without encoding, but rewrite the header. If you're willing to share the files, I can take a look at them tonight. Either through the email on my GitHub profile or nyxholas on the ABS Discord work. It might be nice to see all 3 of the original files to see what differences there are between them.
Author
Owner

@advplyr commented on GitHub (May 23, 2024):

VLC media player is not a good way to test if the file is accurate because VLC will do a lot of magic behind the scenes to get even corrupted files to play.

Native audio players on mobile devices and audio players in browsers are going to use the duration set in the metadata, which in your case is incorrect.

As @nichwall said, you can typically fix these issues with that line from ffmpeg.

@advplyr commented on GitHub (May 23, 2024): VLC media player is not a good way to test if the file is accurate because VLC will do a lot of magic behind the scenes to get even corrupted files to play. Native audio players on mobile devices and audio players in browsers are going to use the duration set in the metadata, which in your case is incorrect. As @nichwall said, you can typically fix these issues with that line from ffmpeg.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2003