Open StefanDorschu opened 1 year ago
I would like to merge an audiobook that consists of multiple folder (CD1, CD2 etc.).
This should work. m4b-tool
performs a natural sort of files before merging anything, which means that the order would be:
CD 1/1 - chapter1.mp3
CD 1/2 - chapter2.mp3
CD 1/3 - chapter3.mp3
...
CD 2/1 - chapter15.mp3
CD 2/2 - chapter16.mp3
...
If it does not work like you would expect, I need:
find -type f /path/to/audiobook
, on windows use dir /s /path/to/audiobook
)m4b-tool merge -o output.m4b input/
)Best Andreas
Hi Andreas,
i found my problem :) I thought i would be using your files, instead i'm running the "docker"-fork of seanap.
I think the way it is automating the task is causing the problem.
The code which is run is
https://github.com/seanap/auto-m4b/blob/main/auto-m4b-tool.sh
In line 71 the way is handling nested folders is the problem. But i think my skills are too limited here to fix ist :(
Best regards and thank you for all of your help,
Stefan
instead i'm running the "docker"-fork of seanap.
While I appreciate the fact, that other people are using my tools to create scripts like that, I think that the specific script is overcomplicating everything and causing a lot of unnecessary load on the file system... instead of using the --batch-pattern
feature, it tries to move files around and does backups of the original folder where not necessary.
I personally think that a tool like inotifywait
would have been the right choice to implement this (instead of a while loop). See https://www.baeldung.com/linux/monitor-changes-directory-tree for details.
But i think my skills are too limited here to fix ist :(
Are you running linux? If so you could do the following very simple approach:
#!/bin/sh
CPU_CORES="2"
INPUT_PATH="/path/to/my/audiobooks/input/"
OUTPUT_PATH="/path/to/my/audiobooks/output/"
while [ true ]; do
docker run -it -rm -u $(id -u):$(id -g) -v "$INPUT_PATH":/mnt -v "$OUTPUT_PATH":/output sandreas/m4b-tool:latest merge --jobs=$CPU_CORES --no-cache -v --batch-pattern="/mnt/%g/%a/%s/%p - %n/" --batch-pattern="/mnt/%g/%a/%n/" "/mnt/" --output-file="/output/" --max-chapter-length=300,900 --adjust-for-ipod --audio-channels=1 --audio-bitrate=64k --audio-samplerate=22050 --audio-codec=libfdk_aac --audio-profile=aac_he --equate=name,album --ignore-source-tags --prepend-series-to-longdesc --silence-min-length=1000 --chapter-algo=grouping --skip-cover-if-exists
# wait 5 Minutes to prevent to much filesystem load
sleep 300
done
That's it... Now you can put your files into an organized structure like this:
For series add the part number (1 -
):
/path/to/my/audiobooks/input/Fantasy/J.K. Rowling/Harry Potter/1 - Harry Potter und der Stein der Weisen
For single books, use
/path/to/my/audiobooks/input/Fantasy/Alexej Pehov/Dunkeljäger/
Possible issues:
mv "/new/audiobooks/Dunkeljäger" "/path/to/my/audiobooks/input/Fantasy/Alexej Pehov/"
) to prevent partial or damaged output content--batch-pattern
according to that structure (e.g. https://www.audiobookshelf.org/docs#faq).I'm currently working on reorganising my personal filesystem structure to support AudioBookShelf. As soon as it's done, I plan to update the documentation with a guide supporting it. Another feature I'm planning for tone
is to watch a filesystem structure and run a script / command (something like tone watch /path/to/audiobooks --run="m4b-tool merge /path/to/audiobooks/ -o /output/ ..." --no-changes-for="300"
. That would make auto-m4b-tool
obsolete, but I've not even started to implement this feature.
Thank you again. Currently i'm trying to setup the docker container (on a synology nas). I have only used docker compose yet, so still need some time/help to get it running :)
I would like to merge an audiobook that consists of multiple folder (CD1, CD2 etc.).
I can not copy the files to one folder, because then the chapters are in the wrong order as the tracks are numbered from 1 to... in each folder.
When i try to merge the parent folder this audiobook is moved to the "fix"-folder.
Best regards,
Stefan