Tool is skipping first few chapters
Closed this issue · 15 comments
Not really a flaw in the software (i think) but looking at your script and the originators scripts i'm having issues - I copied your script and added my own paths - but almost all the books are starting on the 6th or 7th chapter (6th or 7th file) and then going from there - and i have no idea why it isn't starting on chapter 1
#!/bin/bash
set n to 1
n=1
continue until $n 5
while [ $n -ge 0 ]
do
if ls -d / 2> /dev/null
then
echo Folder Detected
string1="/untagged/"
string2=".m4b"
string4=".log"
for file in ; do
if [ -d "$file" ]; then
mpthree=$(find . -maxdepth 2 -type f -name ".mp3" | head -n 1)
string3=$string1$file$string2
string5=$string1$file$string4
echo Sampling $mpthree
bit=$(ffprobe -hide_banner -loglevel 0 -of flat -i "$mpthree" -select_streams a -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1)
echo Bitrate = $bit
echo The folder "$file" will be merged to "$string3"
echo Starting Conversion
docker run -it --rm -u $(id -u):$(id -g) -v /mnt/d/pooo:/mnt -v /mnt/d/pooo1:/untagged m4b-tool merge "$file" -n -q --audio-bitrate="$bit" --skip-cover --use-filenames-as-chapters --audio-codec=libfdk_aac --jobs=4 --output-file="$string3" --logfile="$string5"
mv /mnt/d/pooo/"$file" /mnt/d/pooo2/
mv /mnt/d/pooo1/"$file".chapters.txt /mnt/d/pooo1/chapters
echo Finished Converting
echo Deleting duplicate mp3 audiobook folder
fi
done
else
rm -r /mnt/d/pooo2/ 2> /dev/null
echo No folders detected, next run 5min...
sleep 5m
fi
done
EDIT: Its worse than that - here is an example where it started in the single digits then skips the 50's
It shouldn't matter - but i'm running this in WSL2 with the container setup that you recommended
the files are on windows storage mapped through normal /mnt/"driveletter"
I've done a couple hundred books now and have not seen any issues like this. This script is working off of your filenames. From the picture it looks like your naming goes 04-Chapter-9 to 05-Chapter-55. Are the original files named like that? Also, it does looks like the track number matches the Chapter, can you sort by track?
What program are you using to view the m4b chapters? What does the output of the chapters.txt file look like?
This script should be naming the m4b file based on the folder name. Those .finish files look like the temp files m4b-tool makes before it combines everything.
Yes - but its skipping chapter 1-5 and jumping directly to chapter 5 and putting a 6 on it
I know the error lies with me but i'm not sure what i'm doing wrong
When I was testing this I copied a folder of an mp3 music album (smaller size, quicker builds) and just ran the docker run...
command varying the options till it was how I want, then I put that command in the script and tested some more. In mp3tag under Tools > Options > Advanced check "List chapters as separate files" This should show you the chapter outputs.
I'm not sure what would cause it skip the first few chapters.
chapters.log
This was my chapters file for this run
Yeah -i'm having weird stuff and i'm slightly out of my depth - this is the docker run i used and it literally does nothing - just runs for a second and goes to new line
docker run -it --rm -u
Excuse my poo folder names :)
So when just running the docker command outside of the script you need to change "$file"
to the folder name, just remove --audio-bitrate="$bit"
-q
-n
and then update the --logfile to /untagged/testbook1.log and --output-file to /untagged/testbook1.m4b
Add the music test folder to /mnt/d/pooo , run the docker command, and the output should be in /mnt/d/pooo1
Yeah before it finished - this is how the files looked
Not only is it skipping 1-5 it goes from 9 to 54 entirely
This is all the log says on completion
ERROR 89238ms could not convert /mnt/Brandon Sanderson - The Way of Kings_ Book One of The Stormlight Archi/Chapter 6.mp3 to /untagged/Brandon Sanderson - The Way of Kings_ Book One of The Stormlight Archi-tmpfiles/01-Chapter 6-finished.m4b
Could it be a permissions issue?
I guess? - thought i had something using wsl 2 - just tried again with different book and similar outcome
And if it was permissions - would the program be able to delete the entire folder at the end of the script?
This .sh script was deleting the folder, but the m4b-tool docker may have different permissions. Very odd though that it would always be the first few files.
yeah - sorry i will try this in a more native setup as i feel like that is the issue
I have a server running unraid but i am bad getting non template dockers running
Yeah i wanted to dive into wsl 2 - but i think this may be a suboptimal way to do it
Thank you for your work on audiobook setup in Plex - i've been running my own stuff with audiobook agent for a long time