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

Chapter names are not being setup correctly. #257

Open
jbuddha opened this issue Apr 1, 2024 · 6 comments
Open

Chapter names are not being setup correctly. #257

jbuddha opened this issue Apr 1, 2024 · 6 comments

Comments

@jbuddha
Copy link

jbuddha commented Apr 1, 2024

I have a bunch of MP3 files in a folder with names such as these.
image

Their individual mp3 file's title tag is also set as Unit 01, Unit 02 etc., I tried to run following commands once with --use-filenames-as-chapters and once without using that flag.

m4b-tool merge "." --debug --output-file="Italian L1.m4b" --artist=X --skip-cover --name="Italian L1" --use-filenames-as-chapters
m4b-tool merge "." --debug --output-file="X Italian L1.m4b" --artist=X --skip-cover --name="X Italian L1"

In both cases, my chapters titles are not using the file name or title tag and producing following output in chapters section. How can I have the chapter names as Unit 01, Unit 02 etc? Right now, the only way I can think of solving this problem is run above command once, copy the chapters meta data output and create chapters.txt manually and delete generated temp files, and generated m4b and rerun the above command to generate final m4b file to have correct chapter names. The tool is great except for this minor issue I'm unable to solve.

chapters         
## total-duration:: 15:26:06.229
00:00:00.000 1.1
00:27:54.654 2.1
00:55:37.838 3
01:23:46.517 4
01:52:28.346 5
02:21:59.468 6
02:50:39.155 7
03:19:52.278 8
03:48:04.510 9
04:17:55.145 10
04:46:19.942 11
05:14:42.074 12
05:42:37.535 13
06:12:59.543 14
06:42:08.931 15
07:10:23.070 16
07:39:43.952 17
08:09:08.021 18
08:38:47.528 19
09:07:25.150 20
09:34:03.656 21
10:02:46.477 22
10:31:20.286 23
11:01:36.365 24
11:28:42.795 25
11:55:49.956 26
12:22:18.482 27
12:52:08.151 28
13:19:45.222 29
13:47:04.190 30
14:13:03.981 1.2
14:52:37.774 2.2

Can you tell what I'm doing incorrectly here?

@sandreas
Copy link
Owner

sandreas commented Apr 1, 2024

Can you tell what I'm doing incorrectly here?

This is probably a bug in the old chapter algorithm. This is hard to fix, but I'll try it as soon as I have more time.
In the meantime you could try --chapter-algo=grouping or --chapter-algo=legacy to work around this problem.

Thanks for reporting, I hope it helps.

@jbuddha
Copy link
Author

jbuddha commented Apr 1, 2024

I've tried --chapter-algo=grouping and it failed with the following error at the end.

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in phar:///opt/homebrew/Cellar/m4b-tool/pre-release/bin/m4b-tool/src/library/Command/AbstractCommand.php on line 441
PHP Deprecated:  trim(): Passing null to parameter #1 ($string) of type string is deprecated in phar:///opt/homebrew/Cellar/m4b-tool/pre-release/bin/m4b-tool/src/library/Command/AbstractCommand.php on line 441

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in phar:///opt/homebrew/Cellar/m4b-tool/pre-release/bin/m4b-tool/src/library/Command/AbstractCommand.php on line 441
==== current tag ====
- tag has not changed since the last improver


==> trying improver AdjustChaptersByGroupLogic
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in phar:///opt/homebrew/Cellar/m4b-tool/pre-release/bin/m4b-tool/src/library/Chapter/ChapterGroup/ChapterLengthCalculator.php on line 231

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in phar:///opt/homebrew/Cellar/m4b-tool/pre-release/bin/m4b-tool/src/library/Chapter/ChapterGroup/ChapterLengthCalculator.php on line 231
an error occured, that has not been caught:
Array
(
    [type] => 1
    [message] => Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)
    [file] => phar:///opt/homebrew/Cellar/m4b-tool/pre-release/bin/m4b-tool/src/library/Chapter/ChapterGroup/ChapterLengthCalculator.php
    [line] => 231
)

Then I have tried --chapter-algo=legacy

This didn't fail but this just gave same output of chapter names to be incorrect as in the original issue.

However I noticed there is another parameter --no-chapter-reindexing this is has worked. So, I ran the following command.

m4b-tool merge "." --debug --output-file="Italian L4.m4b" 
                                 --series="Italian" 
                                 --series-part="L4" 
                                 --artist=XXX --skip-cover
                                 --name="Italian L4" 
                                 --use-filenames-as-chapters 
                                 --no-chapter-reindexing

This produced following chapters automatically and their order is retained. In the original output.

00:00:00.000 Italian 4 - Unit 01
00:30:36.478 Italian 4 - Unit 02
01:01:28.976 Italian 4 - Unit 03
01:32:01.926 Italian 4 - Unit 04
02:02:35.164 Italian 4 - Unit 05
02:33:06.026 Italian 4 - Unit 06
03:03:00.888 Italian 4 - Unit 07
03:33:16.151 Italian 4 - Unit 08
04:03:53.313 Italian 4 - Unit 09
04:34:21.079 Italian 4 - Unit 10
05:04:35.489 Italian 4 - Unit 11
05:35:13.551 Italian 4 - Unit 12
06:05:39.949 Italian 4 - Unit 13
06:36:26.687 Italian 4 - Unit 14
07:07:09.213 Italian 4 - Unit 15
07:37:37.015 Italian 4 - Unit 16
08:08:07.229 Italian 4 - Unit 17
08:37:53.811 Italian 4 - Unit 18
09:07:43.957 Italian 4 - Unit 19
09:36:02.591 Italian 4 - Unit 20
10:06:48.681 Italian 4 - Unit 21
10:36:49.447 Italian 4 - Unit 22
11:06:55.001 Italian 4 - Unit 23
11:37:06.747 Italian 4 - Unit 24
12:07:52.693 Italian 4 - Unit 25
12:37:34.919 Italian 4 - Unit 26
13:08:19.533 Italian 4 - Unit 27
13:38:28.183 Italian 4 - Unit 28
14:08:39.893 Italian 4 - Unit 29
14:38:57.507 Italian 4 - Unit 30
15:09:30.601 Italian 4 - Reading 01
15:14:14.867 Italian 4 - Reading 02
15:18:23.385 Italian 4 - Reading 03
15:22:35.899 Italian 4 - Reading 04
15:26:38.945 Italian 4 - Reading 05
15:30:32.703 Italian 4 - Reading 06
15:34:49.969 Italian 4 - Reading 07
15:39:05.327 Italian 4 - Reading 08
15:43:16.437 Italian 4 - Reading 09
15:47:25.243 Italian 4 - Reading 10
15:52:22.613 Italian 4 - Reading 11
15:56:13.671 Italian 4 - Reading 12
16:00:53.761 Italian 4 - Reading 13
16:04:59.075 Italian 4 - Reading 14
16:09:16.341 Italian 4 - Reading 15
16:14:09.859 Italian 4 - Reading 16
16:19:02.981 Italian 4 - Reading 17
16:23:47.247 Italian 4 - Reading 18
16:28:21.505 Italian 4 - Reading 19
16:33:15.779 Italian 4 - Reading 20

@jbuddha
Copy link
Author

jbuddha commented Apr 1, 2024

Thanks for quickly responding and giving me idea that I can combine it with other flags. I think we can close the issue as there is a workaround at least. Or keep it open if you want to get to it later.

@sandreas
Copy link
Owner

sandreas commented Apr 1, 2024

@jbuddha Glad it worked. Leave the issue open, there is a lot to fix :-) And maybe someone else will find this and the workaround as long as it is open. Thanks for your effort.

@muellerj
Copy link

muellerj commented Sep 3, 2024

I did find this and found it very useful - thanks! :)

Had the same issue as the OP, without --no-chapter-reindexing, the chapter names from the title tags get replaced by 1, 2, 3, etc.

@thir0n
Copy link

thir0n commented Jan 1, 2025

+1 same issue: I tried to extract chapter names from title but got only incrementing numbers. --no-chapter-reindexing solved it.

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

4 participants