sandreas / m4b-tool

m4b-tool is a command line utility to merge, split and chapterize audiobook files such as mp3, ogg, flac, m4a or m4b
MIT License
1.15k stars 76 forks source link

Invalid format string #180

Closed wvhulle closed 2 years ago

wvhulle commented 2 years ago

I installed m4b-tool and tried the tl;dr command for splitting:

m4b-tool split --audio-format mp3 --audio-bitrate 96k --audio-channels 1 --audio-samplerate 22050 data/World\ Engines\ Destroyer.m4b

However, I get the error

In TimeUnit.php line 97:

  Invalid format string (no match or invalid pattern <#(?P<H>[0-9]+)\:(?P<M>[  
  0-9]+)\:(?P<S>[0-9]+)\.(?P<L>[0-9]+)#>)     

Why is this?

My system is Linux mint 20.3.

wvhulle commented 2 years ago

It looks like some regex (?P<H>[0-9]+)\:(?P<M>[ 0-9]+)\:(?P<S>[0-9]+)\.(?P<L>[0-9]+) is not being matched in the command.

sandreas commented 2 years ago

Which version of m4b-tool are you using? If 0.4.2, try upgrading to the latest pre-release: https://github.com/sandreas/m4b-tool/releases/tag/latest

wvhulle commented 2 years ago

Ok, I installed to the latest version as you described in the link. m4b-tool version doesn't work, so i can't say it is the right version. However, I still get the same error

In TimeUnit.php line 97:

  Invalid format string (no match or invalid pattern <#(?P<H>[0-9]+)\:(?P<M>[  
  0-9]+)\:(?P<S>[0-9]+)\.(?P<L>[0-9]+)#>)  
wvhulle commented 2 years ago

Does it have to do with spaces in my filename?

sandreas commented 2 years ago

Nope, it might be a bug, but I think there is something wrong with your chapters. Try to run:

m4b-tool meta data/World\ Engines\ Destroyer.m4b

and take a look at your chapters... should look similar to this:

## total-duration:: 00:41:53.000
00:00:00.000 Intro
00:00:04.121 Chapter 1
00:01:00.764 Chapter 2

And try to use the --debug flag to get more information.

wvhulle commented 2 years ago

No sorry, after m4b-tool --debug meta data/World\ Engines\ Destroyer.m4b, I get Command "meta" is not defined.. I used the pre-release version you recommended.

sandreas commented 2 years ago

m4b-tool version doesn't work,

try m4b-tool --version

No sorry, after ...

You probably did not use the latest pre-release, because meta is a command, that did not exist with 0.4.2 and is only available in the latest pre-release. Something with your install went wrong, maybe it is because the instructions are less then optimal.

Are you running on docker or plain ubuntu?

wvhulle commented 2 years ago

Yes, it is version 0.4.2. I tried to follow the instructions from your link. https://github.com/sandreas/m4b-tool/releases/tag/latest The docker command doesn't work, so I downloaded your latest release https://github.com/sandreas/m4b-tool/files/8304864/m4b-tool.tar.gz and unpacked it. Then according to the Linux section did sudo mv m4b-tool.phar /usr/local/bin/m4b-tool && sudo chmod +x /usr/local/bin/m4b-tool. Afterwards m4b-tool version gives Command "version" is not defined.. So yeah, maybe a good A-Z install instruction would be good.

wvhulle commented 2 years ago

Now I downloaded the full source code and executed the Docker command.

ERROR: unsatisfiable constraints:
  fdk-aac-dev (missing):
    required by: world[fdk-aac-dev]
The command '/bin/sh -c echo "---- INSTALL BUILD DEPENDENCIES ----"     && apk add --no-cache --update --upgrade --virtual=build-dependencies     autoconf     automake     boost-dev     build-base     gcc     lame-dev     libogg-dev     yasm     nasm     yasm-dev     zlib-dev     freetype-dev     libogg-dev     libtheora-dev     libvorbis-dev     openssl-dev     opus-dev     git     wget && echo "---- INSTALL RUNTIME PACKAGES ----"     && apk add --no-cache --update --upgrade bzip2     ca-certificates     coreutils     curl     file     libtool     freetype     lame     libogg     libvpx     libvorbis     libtheora     libvorbis     openssl     opus     pcre     php7-cli     php7-dom     php7-intl     php7-json     php7-xml     php7-curl     php7-mbstring     php7-simplexml     php7-phar     php7-openssl     php7-zip     pkgconf     pkgconfig     tar     && echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories     && apk add --update fdk-aac-dev     && echo "date.timezone = UTC" >> /etc/php7/php.ini && echo "---- COMPILE FFMPEG ----"     && cd /tmp/     && wget http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz     && tar zxf ffmpeg-${FFMPEG_VERSION}.tar.gz     && rm ffmpeg-${FFMPEG_VERSION}.tar.gz     && cd /tmp/ffmpeg-${FFMPEG_VERSION}     && ./configure     --enable-version3     --enable-gpl     --enable-nonfree     --enable-small     --enable-libmp3lame     --enable-libtheora     --enable-libvorbis     --enable-libopus     --enable-libfdk_aac     --enable-avresample     --enable-libfreetype     --enable-openssl     --disable-debug     --disable-doc     --disable-ffplay     --prefix="/tmp${PREFIX}"      --extra-cflags="-I/tmp${PREFIX}/include"     --extra-ldflags="-L/tmp${PREFIX}/lib"     --extra-libs="-lpthread -lm"     --bindir="/usr/local/bin/"      && make -j4 && make install && make distclean && hash -r && rm -rf /tmp/* && echo "---- COMPILE SANDREAS MP4V2 ----"     && cd /tmp/     && wget https://github.com/sandreas/mp4v2/archive/master.zip     && unzip master.zip     && rm master.zip     && cd mp4v2-master     && ./configure && make -j4 && make install && make distclean && rm -rf /tmp/* && echo "---- COMPILE FDKAAC ----"     && cd /tmp/     && wget https://github.com/nu774/fdkaac/archive/1.0.0.tar.gz     && tar xzf 1.0.0.tar.gz     && rm 1.0.0.tar.gz     && cd fdkaac-1.0.0     && autoreconf -i && ./configure && make -j4 && make install && rm -rf /tmp/* && echo "---- REMOVE BUILD DEPENDENCIES ----"     && apk del --purge build-dependencies' returned a non-zero code: 1
➜  m4b-tool-latest                          37.8s  ma 28 mrt 2022 18:27:22 CEST
wvhulle commented 2 years ago

Okay so this is how i got the latest version:

git clone https://github.com/sandreas/m4b-tool.git

cd m4b-tool

docker build . --build-arg M4B_TOOL_DOWNLOAD_LINK=https://github.com/sandreas/m4b-tool/files/8304864/m4b-tool.tar.gz -t m4b-tool

alias --save m4b-tool='docker run -it --rm -u $(id -u):$(id -g) -v "$(pwd)":/mnt m4b-tool'

m4b-tool --version

But this order of commands is not mentioned anywhere, maybe you can add it?

Dekker500 commented 2 years ago

I realize this issue has been open a while, but when I quickly looked at it, the first thing that came to mind is the final path.

Have you tried to enclose it in quotes? I have had issues on my system that were resolved by simply enclosing all paths in quotes and removing escapes.

Suggest you try: m4b-tool split --audio-format mp3 --audio-bitrate 96k --audio-channels 1 --audio-samplerate 22050 "data/World Engines Destroyer.m4b"

sandreas commented 2 years ago

Ok I investigated this issue and I can't reproduce it...

Problem

In TimeUnit.php line 97:

  Invalid format string (no match or invalid pattern <#(?P<H>[0-9]+)\:(?P<M>[  
  0-9]+)\:(?P<S>[0-9]+)\.(?P<L>[0-9]+)#>)  

Explanation

m4b-tool first dumps the chapters.txt, tries to parse it and then uses the parsed chapters to extract each chapter as audio file by using the timestamps in the dump. And something did go wrong parsing the dump. If I have a chapters file looking like this:

## album-artist: xxx
## artist: yyy
## album: zzz
## title: asdf
##
## total-duration: 01:12:20.558
##
00:00:00.000 asdf 
00:55:33.568 fdsa
00:56:33.838 qwer

and it tries to parse ## album-artist: xxx assuming that it is a timestamp, this fails. And I think this was the problem some pre-releases ago, but it should have been fixed.

Please retry with the latest official docker image, see here for instructions.. It should work now.

If not, feel free to reopen.