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

Running the same command gives inconsistent results - Windows WSL2 Ubuntu 20.04 #222

Open
kanjieater opened this issue Feb 19, 2023 · 8 comments

Comments

@kanjieater
Copy link

I'm not sure if this is an issue with WSL2 as mentioned in #204 or something else.

#204 (comment)

I can run the same command with the docker and get inconsistent results. I'm not sure what this error indicates
image

Could not detect length for file 20-finished.m4b, output 'mp4info version 2.1.1
/tmp/m4b-tool/20-finished.m4b:
ReadChildAtoms: "/tmp/m4b-tool/20-finished.m4b": In atom  missing child atom moov
FindIntegerProperty: no such property - moov.mvhd.modificationTime (src/mp4file.cpp,831)
mp4info: can't open /tmp/m4b-tool/20-finished.m4b
' does not contain a valid length value

I'm simply running a merge command with jobs matching my core count.
docker run -it --rm -u $(id -u):$(id -g) -v "$FOLDER":/mnt sandreas/m4b-tool:latest merge "./$(echo $NAME)_splitted/" --output-file="./$NAME.m4b" --jobs=$(nproc --all)

@kanjieater
Copy link
Author

kanjieater commented Feb 19, 2023

I also switched to hypervisor and am running from windows now. The same thing happens
image

ERROR       41499ms Could not detect length for file 22-finished.m4b, output 'mp4info version 2.1.1
/tmp/m4b-tool/22-finished.m4b:
ReadChildAtoms: "/tmp/m4b-tool/22-finished.m4b": In atom  missing child atom moov
FindIntegerProperty: no such property - moov.mvhd.modificationTime (src/mp4file.cpp,831)
mp4info: can't open /tmp/m4b-tool/22-finished.m4b
' does not contain a valid length value

@sandreas
Copy link
Owner

Mmh strange. Looks like a windows issue, I recently came across the jellyfin docker instructions where it is recommended to use a bind mount instead of a volume to overcome filesystem issues, but I think this is not possible on windows?!

 docker run -it --rm -u $(id -u):$(id -g) \
--mount type=bind,source=$FOLDER,target=/mnt
  sandreas/m4b-tool:latest merge "./$(echo $NAME)_splitted/" --output-file="./$NAME.m4b" --jobs=$(nproc --all)

And could you verify the issue by using an older docker image?

docker pull sandreas/m4b-tool:2022-11-05

@kanjieater
Copy link
Author

kanjieater commented Feb 19, 2023

image

I can confirm it exists on older builds

The mount flag also works but doesn't seem to be related
image

While my job count is accurate at 32 for a i9-13900ks, it seems like this issue happens more for a high job count. Lower job counts like 4 seem to work more consistently. I'm not sure if this is just luck though.

@kanjieater
Copy link
Author

I'm still running into this. I've tried quite a few different methods as mentioned above, but at this point if I need to combine my mp4's into a m4b, how would I do that outside of m4b-tool?

"""
Could not detect length for file 13-finished.m4b, output 'mp4info version 2.1.1
/tmp/m4b-tool/13-finished.m4b:
ReadChildAtoms: "/tmp/m4b-tool/13-finished.m4b": In atom missing child atom moov
FindIntegerProperty: no such property - moov.mvhd.modificationTime (src/mp4file.cpp,831)
mp4info: can't open /tmp/m4b-tool/13-finished.m4b
' does not contain a valid length value
"""

@sandreas
Copy link
Owner

I'm still running into this. I've tried quite a few different methods as mentioned above, but at this point if I need to combine my mp4's into a m4b, how would I do that outside of m4b-tool?

Which docker image are you using? In newer images / recent versions of m4b-tool tone should be used for length detection - i think this is not the case here.

@kanjieater
Copy link
Author

kanjieater commented Apr 12, 2023

I'm still running into this. I've tried quite a few different methods as mentioned above, but at this point if I need to combine my mp4's into a m4b, how would I do that outside of m4b-tool?

Which docker image are you using? In newer images / recent versions of m4b-tool tone should be used for length detection - i think this is not the case here.

The latest docker image was from around 2 months ago it looks so, so I do have and am using version f0c29aaf4f4a .

I'm getting this error still:

Could not detect length for file 06-finished.m4b, output 'mp4info version 2.1.1
/tmp/m4b-tool/06-finished.m4b:
ReadChildAtoms: "/tmp/m4b-tool/06-finished.m4b": In atom  missing child atom moov
FindIntegerProperty: no such property - moov.mvhd.modificationTime (src/mp4file.cpp,831)
mp4info: can't open /tmp/m4b-tool/06-finished.m4b
' does not contain a valid length value

@sandreas
Copy link
Owner

I'm getting this error still:

Mhh, that is strange. Well, I'll investigate this again, may take a while. I already was going to provide another file iterator using system tools like find... this is a really annoying issue. sorry.

@kanjieater
Copy link
Author

I'm getting this error still:

Mhh, that is strange. Well, I'll investigate this again, may take a while. I already was going to provide another file iterator using system tools like find... this is a really annoying issue. sorry.

No problem - I completely agree, it's core functionality that app developers should easily be able to access without you having to do a this much work on your side.

For working around the files not always being picked up I have been using this.

#!/bin/bash

audiobooks_path="/mnt/a/audiobooksm4b/"

# Loop over each audiobook folder
for audiobook_folder in "${audiobooks_path}"/*/
do
  # Print out the name of the audiobook folder
  echo "Merging files in ${audiobook_folder}..."

  # Get the audiobook name
  audiobook_name="$(basename "${audiobook_folder}")"

  # Get the list of mp4 files in the audiobook folder
  mp4_files=$(ls -1v "${audiobook_folder}"*.mp4)

  # Replace audiobooks_path with "./" in each mp4 file path
  mp4_files=$(echo "$mp4_files" | sed "s|${audiobook_folder}|./|g")

  # Wrap each mp4 file path in quotes
  mp4_files=$(echo "$mp4_files" | awk '{printf "\"%s\" ", $0}')

  # Run the m4b-tool Docker container to merge the MP4 files
  docker_cmd="docker run -it --rm -u $(id -u):$(id -g) -v \"${audiobook_folder}\":/mnt sandreas/m4b-tool:latest merge ${mp4_files} --output-file \"./${audiobook_name}.m4b\" --jobs $(nproc --all)"

  echo "$docker_cmd"
  eval "$docker_cmd"
done

Though, I still found I had to check the outputs of the chapters to make sure they matched, as sometimes m4b-tool would make the m4b skipping mp4 files but still creating the m4b. So i'm working around that with this:

https://github.com/kanjieater/AudiobookTextSync/blob/master/merge.py

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