Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hours and minutes are mixed up? #270

Open
OnkelTem opened this issue Jan 26, 2025 · 9 comments
Open

Hours and minutes are mixed up? #270

OnkelTem opened this issue Jan 26, 2025 · 9 comments

Comments

@OnkelTem
Copy link

OnkelTem commented Jan 26, 2025

I merge a directory with MP3 files total length of 13 hours, but the output is a small file with length like 13 minutes.

$ MP4Box -info mybook.m4b
Duration 00:13:55.955
...
Chapters:
        Chapter #1 - 00:00:00.000 - "1"
        Chapter #2 - 00:00:36.807 - "1"
        Chapter #3 - 00:01:17.167 - "2"
        Chapter #4 - 00:01:49.664 - "3"
        Chapter #5 - 00:02:24.251 - "4"
        Chapter #6 - 00:02:54.397 - "5"
        Chapter #7 - 00:03:25.666 - "6"
        Chapter #8 - 00:04:02.160 - "7"
        Chapter #9 - 00:04:25.906 - "8"
        Chapter #10 - 00:04:49.051 - "9"
        Chapter #11 - 00:05:25.989 - "10"
        Chapter #12 - 00:05:50.571 - "11"
        Chapter #13 - 00:06:22.676 - "12"
        Chapter #14 - 00:06:59.196 - "13"
        Chapter #15 - 00:07:28.140 - "14"
        Chapter #16 - 00:08:08.735 - "15"
        Chapter #17 - 00:08:35.433 - "16"
        Chapter #18 - 00:09:12.162 - "17"
        Chapter #19 - 00:09:42.856 - "18"
        Chapter #20 - 00:10:09.371 - "19"
        Chapter #21 - 00:10:44.036 - "20"
        Chapter #22 - 00:11:19.720 - "21"
        Chapter #23 - 00:11:57.076 - "22"
        Chapter #24 - 00:12:29.573 - "23"
        Chapter #25 - 00:12:55.513 - "24"
        Chapter #26 - 00:13:31.902 - "25"

During conversion it goes too fast, jumping from file to file.

What could be a reason?

I use the docker image.

@sandreas
Copy link
Owner

What could be a reason?

Sounds strange but in the last weeks I did some pretty invasive changes to the code and build system.

To investigate further I would need the full m4b-tool command (docker command) you ran to create the file and if you could provide it, the log file when using the --debug flag (be aware that the logfile might contain user specific data you might want to remove before uploading).

@OnkelTem
Copy link
Author

OnkelTem commented Jan 27, 2025

Hi, Andreas!

Thank you for quick reply. I left only 3 mp3s out of dozens to reduce the output. Here is what I get:

$ docker run -it --rm -u $(id -u):$(id -g) -v "$(pwd)":/mnt sandreas/m4b-tool:latest merge DoA --output-file=DoA.m4b --debug

Output:

INFO            0ms m4b-tool 0.5.1, OS: Linux (Welcome to Alpine Linux 3.20
Kernel \r on an \m (\l))
DEBUG           0ms 'ffmpeg' '-hide_banner' '-version'
DEBUG           3ms == load input files ==
NOTICE          3ms found 3 files to convert
DEBUG           3ms 000.mp3
001.mp3
002.mp3
NOTICE          3ms searching for cover in DoA
NOTICE          3ms cover not found or not specified
DEBUG           3ms 'ffmpeg' '-nostats' '-loglevel' 'panic' '-hide_banner' '-i' 'DoA/000.mp3' '-an' '-vcodec' 'copy' 'DoA/cover.jpg'
NOTICE         26ms extracted cover to DoA/cover.jpg
NOTICE         27ms preparing conversion with 1 simultaneous job, please wait...
DEBUG          27ms 'ffmpeg' '-hide_banner' '-i' 'DoA/000.mp3' '-map_metadata' '0' '-max_muxing_queue_size' '9999' '-strict' 'experimental' '-movflags' '+faststart' '-vn' '-ab' '64k' '-ar' '22050' '-ac' '0' '-acodec' 'aac' '-f' 'mp4' '/tmp/m4b-tool/1-converting.m4b'
DEBUG         654ms 'ffmpeg' '-hide_banner' '-i' 'DoA/001.mp3' '-map_metadata' '0' '-max_muxing_queue_size' '9999' '-strict' 'experimental' '-movflags' '+faststart' '-vn' '-ab' '64k' '-ar' '22050' '-ac' '0' '-acodec' 'aac' '-f' 'mp4' '/tmp/m4b-tool/2-converting.m4b'
DEBUG        1510ms 'ffmpeg' '-hide_banner' '-i' 'DoA/002.mp3' '-map_metadata' '0' '-max_muxing_queue_size' '9999' '-strict' 'experimental' '-movflags' '+faststart' '-vn' '-ab' '64k' '-ar' '22050' '-ac' '0' '-acodec' 'aac' '-f' 'mp4' '/tmp/m4b-tool/3-converting.m4b'
NOTICE       2308ms searching for cover in DoA
NOTICE       2308ms using cover DoA/cover.jpg
DEBUG        2308ms ffmpeg concat file /tmp/m4b-tool/tmp_DoA.m4b.listing.txt content:
DEBUG        2309ms ------ start ------
file '/tmp/m4b-tool/1-finished.m4b'
file '/tmp/m4b-tool/2-finished.m4b'
file '/tmp/m4b-tool/3-finished.m4b'

------ end ------
NOTICE       2309ms merging 3 files into /tmp/m4b-tool/tmp_DoA.m4b, this can take a while
DEBUG        2309ms 'ffmpeg' '-hide_banner' '-f' 'concat' '-safe' '0' '-vn' '-i' '/tmp/m4b-tool/tmp_DoA.m4b.listing.txt' '-max_muxing_queue_size' '9999' '-c' 'copy' '-f' 'mp4' '/tmp/m4b-tool/tmp_DoA.m4b'
INFO         2327ms improving tags...
INFO         2327ms ==> trying improver CueSheet
DEBUG        2327ms ==== current tag ====
INFO         2327ms type             : 2
INFO         2327ms 
INFO         2327ms Empty tag fields : album, albumartist, artist, chapters, comment, copyright, cover, description, disk, disks, encoded-by, encoder, genre, grouping, language, longdesc, lyrics, name, performer, publisher, purchaseDate, sortAlbumArtist, sortWriter, sortalbum, sortartist, sortname, track, tracks, writer, year
INFO         2327ms 

INFO         2327ms ==> trying improver Ffmetadata
INFO         2327ms ffmetadata.txt not found - tags not improved
DEBUG        2327ms ==== current tag ====
DEBUG        2327ms - tag has not changed since the last improver
INFO         2327ms 

INFO         2327ms ==> trying improver ChaptersTxt
INFO         2327ms chapters.txt not found - tags not improved
DEBUG        2327ms ==== current tag ====
DEBUG        2327ms - tag has not changed since the last improver
INFO         2327ms 

INFO         2328ms ==> trying improver ChaptersFromOverdrive
DEBUG        2328ms 'ffmpeg' '-hide_banner' '-i' 'DoA/000.mp3' '-f' 'ffmetadata' '-'
DEBUG        2342ms 'ffmpeg' '-hide_banner' '-i' 'DoA/001.mp3' '-f' 'ffmetadata' '-'
DEBUG        2353ms 'ffmpeg' '-hide_banner' '-i' 'DoA/002.mp3' '-f' 'ffmetadata' '-'
INFO         2365ms no overdrive chapters found - tags not improved
DEBUG        2365ms ==== current tag ====
DEBUG        2365ms - tag has not changed since the last improver
INFO         2365ms 

INFO         2365ms ==> trying improver ChaptersFromFileTracks
DEBUG        2365ms 'ffmpeg' '-hide_banner' '-i' '/tmp/m4b-tool/1-finished.m4b' '-f' 'ffmetadata' '-'
DEBUG        2376ms 'tone' 'dump' '/tmp/m4b-tool/1-finished.m4b' '--format' 'json' '--query' '$.audio.duration'
DEBUG        2515ms 'ffmpeg' '-hide_banner' '-i' '/tmp/m4b-tool/2-finished.m4b' '-f' 'ffmetadata' '-'
DEBUG        2522ms 'tone' 'dump' '/tmp/m4b-tool/2-finished.m4b' '--format' 'json' '--query' '$.audio.duration'
DEBUG        2662ms 'ffmpeg' '-hide_banner' '-i' '/tmp/m4b-tool/3-finished.m4b' '-f' 'ffmetadata' '-'
DEBUG        2672ms 'tone' 'dump' '/tmp/m4b-tool/3-finished.m4b' '--format' 'json' '--query' '$.audio.duration'
DEBUG        2809ms ==== current tag ====
INFO         2809ms chapters         
INFO         2809ms ## total-duration:: 00:01:49.664
00:00:00.000 1
00:00:36.807 1
00:01:17.167 2
INFO         2809ms Empty tag fields : album, albumartist, artist, comment, copyright, cover, description, disk, disks, encoded-by, encoder, genre, grouping, language, longdesc, lyrics, name, performer, publisher, purchaseDate, sortAlbumArtist, sortWriter, sortalbum, sortartist, sortname, track, tracks, writer, year
INFO         2809ms chapter count changed from 0 to 3
INFO         2809ms 

INFO         2809ms ==> trying improver MetadataJson
INFO         2809ms no metadata.json found - tags not improved
DEBUG        2809ms ==== current tag ====
DEBUG        2809ms - tag has not changed since the last improver
INFO         2809ms 

INFO         2809ms ==> trying improver BuchhandelJson
INFO         2809ms no buchhandel.json found - tags not improved
DEBUG        2809ms ==== current tag ====
DEBUG        2809ms - tag has not changed since the last improver
INFO         2809ms 

INFO         2809ms ==> trying improver BookBeatJson
INFO         2809ms no bookbeat.json found - tags not improved
DEBUG        2809ms ==== current tag ====
DEBUG        2809ms - tag has not changed since the last improver
INFO         2809ms 

INFO         2809ms ==> trying improver OpenPackagingFormat
INFO         2809ms metadata.opf not found - tags not improved
DEBUG        2810ms ==== current tag ====
DEBUG        2810ms - tag has not changed since the last improver
INFO         2810ms 

INFO         2810ms ==> trying improver AudibleTxt
INFO         2810ms no audible.txt found - tags not improved
DEBUG        2810ms ==== current tag ====
DEBUG        2810ms - tag has not changed since the last improver
INFO         2810ms 

INFO         2810ms ==> trying improver AudibleJson
INFO         2810ms no audible.json found - tags not improved
DEBUG        2810ms ==== current tag ====
DEBUG        2810ms - tag has not changed since the last improver
INFO         2810ms 

INFO         2810ms ==> trying improver M4bToolJson
INFO         2810ms m4b-tool.json not found - tags not improved
DEBUG        2810ms ==== current tag ====
DEBUG        2810ms - tag has not changed since the last improver
INFO         2810ms 

INFO         2810ms ==> trying improver Description
INFO         2810ms description.txt not found - tags not improved
DEBUG        2810ms ==== current tag ====
DEBUG        2810ms - tag has not changed since the last improver
INFO         2810ms 

INFO         2810ms ==> trying improver ContentMetadataJson
INFO         2810ms content_metadata_*.json not found - tags not improved
DEBUG        2810ms ==== current tag ====
DEBUG        2810ms - tag has not changed since the last improver
INFO         2810ms 

INFO         2810ms ==> trying improver AudibleChaptersJson
INFO         2811ms content_metadata_*.json not found - tags not improved
DEBUG        2811ms 'ffmpeg' '-nostats' '-loglevel' 'panic' '-hide_banner' '-i' '/tmp/m4b-tool/tmp_DoA.m4b' '-vn' '-c:a' 'copy' '-f' 'crc' '-'
DEBUG        2817ms 'ffmpeg' '-hide_banner' '-i' '/tmp/m4b-tool/tmp_DoA.m4b' '-af' 'silencedetect=noise=-30dB:d=1.75' '-f' 'null' '-'
NOTICE       2817ms running silence detection for file /tmp/m4b-tool/tmp_DoA.m4b with min length 00:00:01.750
NOTICE       2869ms silence detection finished
DEBUG        2870ms ==== current tag ====
DEBUG        2870ms - tag has not changed since the last improver
INFO         2870ms 

INFO         2870ms ==> trying improver AdjustTooLongChapters
INFO         2870ms no chapter length adjustment required (max chapter length not provided or empty chapter list)
DEBUG        2870ms ==== current tag ====
DEBUG        2870ms - tag has not changed since the last improver
INFO         2870ms 

INFO         2870ms ==> trying improver AdjustTooShortChapters
INFO         2870ms no too short chapter length adjustment required (no too long chapters found)
DEBUG        2870ms ==== current tag ====
DEBUG        2870ms - tag has not changed since the last improver
INFO         2870ms 

INFO         2870ms ==> trying improver InputOptions
INFO         2870ms input options improved the following 2 properties:
INFO         2870ms           cover: <empty> => DoA/cover.jpg
INFO         2870ms         encoder: <empty> => m4b-tool 0.5.1
DEBUG        2871ms ==== current tag ====
INFO         2871ms cover            : DoA/cover.jpg, 600x595
INFO         2871ms encoder          : m4b-tool 0.5.1
INFO         2871ms Empty tag fields : album, albumartist, artist, comment, copyright, description, disk, disks, encoded-by, genre, grouping, language, longdesc, lyrics, name, performer, publisher, purchaseDate, sortAlbumArtist, sortWriter, sortalbum, sortartist, sortname, track, tracks, writer, year
INFO         2871ms 

DEBUG        2871ms 'ffmpeg' '-hide_banner' '-i' 'DoA/000.mp3' '-f' 'ffmetadata' '-'
DEBUG        2881ms tagFile - filename: /tmp/m4b-tool/tmp_DoA.m4b
DEBUG        2881ms full tag: {"album":"...","albumArtist":"...","artist":"...","comment":"...","cover":"DoA\/cover.jpg","encoder":"m4b-tool 0.5.1","genre":"Audiobook","title":"00","type":2,"writer":"...","language":"eng"}
DEBUG        2881ms === tone.json ===
DEBUG        2881ms {
    "meta": {
        "album": "...",
        "albumArtist": "...",
        "artist": "...",
        "comment": "...",
        "encodingTool": "m4b-tool 0.5.1",
        "genre": "Audiobook",
        "title": "00",
        "itunesMediaType": 2,
        "composer": "...",
        "chapters": [
            {
                "start": 0,
                "length": 36807,
                "title": "1"
            },
            {
                "start": 36807,
                "length": 40360,
                "title": "1"
            },
            {
                "start": 77167,
                "length": 32497,
                "title": "2"
            }
        ]
    }
}
DEBUG        2881ms 'tone' 'tag' '--meta-cover-file' 'DoA/cover.jpg' '--meta-tone-json-file' '/tmp/tonefhafpm' '/tmp/m4b-tool/tmp_DoA.m4b'
NOTICE       3081ms tagged file tmp_DoA.m4b (artist: Descent of Angels, name: 00, chapters: 3)
NOTICE       3082ms moved temporary tmp_DoA.m4b to DoA.m4b
NOTICE       3082ms successfully merged 3 files to DoA.m4b
DEBUG        3082ms 'ffmpeg' '-hide_banner' '-i' 'DoA.m4b' '-f' 'ffmetadata' '-'
DEBUG        3097ms 'tone' 'dump' 'DoA.m4b' '--format' 'json' '--query' '$.audio.duration'
DEBUG        3235ms Final metadata:
album            : ...
albumartist      : ...
artist           : ...
comment          : ....
cover            : embedded jpeg, 600x595
encoder          : Lavf59.16.100
genre            : Audiobook
name             : 00
type             : 2
writer           : ...

chapters         
## total-duration:: 00:01:49.000
00:00:00.000 1
00:00:36.807 1
00:01:17.167 2

Empty tag fields : copyright, description, disk, disks, encoded-by, grouping, language, longdesc, lyrics, performer, publisher, purchaseDate, sortAlbumArtist, sortWriter, sortalbum, sortartist, sortname, track, tracks, year
total estimated duration: 109710

MP4Box output:

$ MP4Box -info DoA.m4b 
# Movie Info - 3 tracks - TimeScale 1000
Duration 00:01:49.710
Fragmented: no
Major Brand isom - version 512 - compatible brands: isom iso2 mp41
Created: UNKNOWN DATE

Chapters:
        Chapter #1 - 00:00:00.000 - "1"
        Chapter #2 - 00:00:36.807 - "1"
        Chapter #3 - 00:01:17.167 - "2"

iTunes Info:
        tool: Lavf59.16.100
        title: 00
        artist: ...
        writer: ...
        comment: ...
        A9gen: Audiobook
        album_artist: ...
        album: ...
        media: 2
        gapless: yes
        A9nrt: ...
        cover: JPEG File
1 UDTA types: 
        chpl: 

# Track 1 Info - ID 1 - TimeScale 22050
Media Duration 00:01:49.709 
Track has 1 edits: track duration is 00:01:49.710
Track flags: Enabled In Movie
Media Info: Language "Undetermined (und)" - Type "soun:mp4a" - 2363 samples
Alternate Group ID 1
MPEG-4 Audio AAC LC (AOT=2 implicit) - 2 Channel(s) - SampleRate 22050
        RFC6381 Codec Parameters: mp4a.40.2
        All samples are sync
        Max sample duration: 2752 / 22050

# Track 2 Info - ID 3 - TimeScale 1000
Media Duration 00:01:49.000  (recomputed 00:01:49.664)
Track flags: Enabled In Movie In Preview
Media Info: Language "Undetermined (und)" - Type "vide:jpeg" - 3 samples
Visual Sample Entry Info: width=1 height=1 (depth=24 bits)
Visual Track layout: x=0 y=0 width=1 height=1
JPEG Image - Resolution 1 x 1
        RFC6381 Codec Parameters: mp4v.6C
        All samples are sync
        Max sample duration: 40360 / 1000

# Track 3 Info - ID 2 - TimeScale 1000
Media Duration 00:01:49.000  (recomputed 00:01:49.664)
Track flags: Enabled In Movie In Preview
Media Info: Language "Undetermined (und)" - Type "text:text" - 3 samples
Unknown Text Stream
        Size 0 x 0 - Translation X=0 Y=0 - Layer 2
        RFC6381 Codec Parameters: text
        All samples are sync
        Max sample duration: 40360 / 1000

I can actually upload files somewhere for you to simplify investigation. I'm pretty sure there's something wrong with the source files, but none of players or metadata fetchers signal of a problem.

@sandreas
Copy link
Owner

Thanks for providing the required information. Let me first try to reproduce this without the files, if it does not work, I'll report back.

@sandreas
Copy link
Owner

Mmh, seems that I can't reproduce the problem on my system with my files, BUT

Before you upload your files please ensure that these files are not under copyright - if they are, I would invite you to a private repository, where you could share a link to the files required to reproduce the issue. They will be used only to reproduce the issue and deleted afterwards.

The only things I can think of:

  • You use tone 0.2.4 (in the docker file) and a bug was fixed in 0.2.5(unlikely)
  • Your files must have some kind of problem

I'm planning to release a new docker image with updated tone 0.2.5 soon, but there are a few things I'd like to fix before releasing the next version 0.5.2.

For the sake of completeness my results (without mixed up times):

# ... removed the processing output ...

chapters         
## total-duration:: 01:56:18.931
00:00:00.000 00 - Introduction, by T. T. Wilkinson
00:14:57.648 01 - Fragment of an Ancient Ballad of a Tyrannical Husband\; The Old Man and his Wife
00:28:56.442 02 - A Trafford and Byron Feud\; The Bewsey Tragedy and its Legend
00:44:14.609 03 - The Lancashire Heroes\; Flodden Field
01:03:52.960 04 - A Love Song\; A Balade of Maryage
01:08:43.698 05 - The Blessed Conscience
01:24:52.113 06 - The Radcliffe Tragedy of Fair Ellen
01:35:52.808 07 - James I. and the Loin of Beef
01:37:47.547 08 - Warrikin Fair
01:43:58.022 09 - Brigadier Macintosh's Escape and Farewell

Empty tag fields : albumartist, copyright, cover, description, disk, disks, encoded-by, grouping, language, longdesc, lyrics, performer, publisher, purchaseDate, sortAlbumArtist, sortWriter, sortalbum, sortartist, sortname, tracks, writer, year
total estimated duration: 6978931

@OnkelTem
Copy link
Author

Sorry for the delay. I will upload it to a private place, sure. Please tell me how I can share the link with you

@sandreas
Copy link
Owner

Sorry for the delay. I will upload it to a private place, sure. Please tell me how I can share the link with you

You should have received an invite to a private repo (m4b-tool-private). Please read the README.md before sharing anything.

@OnkelTem
Copy link
Author

Done.

@sandreas
Copy link
Owner

sandreas commented Feb 1, 2025

I think I reproduced the problem. Seems to be definitely something about the files, but I'll have to recheck. At least I now have a starting point, thank you for sharing :-)

@sandreas
Copy link
Owner

sandreas commented Feb 1, 2025

So the problem seems to be out of my control... Either it is a file problem (so that the file is really damaged or something) or ffmpeg is at least THINKING so (ffmpeg bug). This is the ffmpeg only log on this file - unfortunately ffmpeg exits with 0 (so basically saying that everything worked) and I can't detect whats wrong:

ffmpeg '-hide_banner' '-i' '000.mp3' '-map_metadata' '0' '-max_muxing_queue_size' '9999' '-strict' 'experimental' '-movflags' '+faststart' '-vn' '-ab' '64k' '-ar' '22050' '-ac' '0' '-acodec' 'aac' '-f' 'mp4' '1-converting.m4b'

...
[mp3float @ 0x1dd48380] Header missingate=   0.0kbits/s speed=36.2x    
[aist#0:0/mp3 @ 0x1dd43b00] [dec:mp3float @ 0x1dda9a00] Error submitting packet to decoder: Invalid data found when processing input
[mp3float @ 0x1dd48380] overread, skip -7 enddists: -6 -6
[mp3float @ 0x1dd48380] overread, skip -8 enddists: -1 -1
...

Checking the original files with tone gives the correct length and the correct metadata, so what you could try is to cleanup the files by converting it with another encoding tool (e.g. sox or lame - maybe audacity instead of ffmpeg), since everytime I use ffmpeg the file is broken afterwards:

ffmpeg -i 000.mp3 000.wav

produces a file with the length 36 seconds, 780ms (wav) where the original file is 19 min 43s (mp3).

Trying to submit an issue to ffmpeg is probably pointless, it probably won't get fixed soon.

Let me know if you are ok with me closing the ticket, because it is probably not an issue with m4b-tool or tone, but pretty likely a damaged file or an ffmpeg issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants