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

cannot read metadata, file does not exist #67

Open
Arsur opened this issue Jan 5, 2020 · 26 comments
Open

cannot read metadata, file does not exist #67

Arsur opened this issue Jan 5, 2020 · 26 comments

Comments

@Arsur
Copy link

Arsur commented Jan 5, 2020

I always get the "error cannot read metadata, file does not exist"

I used a docker container from version 0.3.x in the past and now builded a new one with version 0.4.2

The same commands stopped working. Is there a way to see what is mounted in the docker container? (docker exec -it /bin/bash)

m4b-tool --version is working...

@Arsur
Copy link
Author

Arsur commented Jan 5, 2020

Found the problem. Missing slash in input file "data/audiobook" has to be /data/audiobook

@Arsur Arsur closed this as completed Jan 5, 2020
@MrTechGadget
Copy link

@Arsur I'm also struggling with this error with these newer versions, can you tell me what your alias command is?

@sandreas
Copy link
Owner

sandreas commented Jan 19, 2020

TLDR;

  • Change into the home-directory of your audiobooks (e.g. cd /home/sandreas)
  • Convert the audiobooks using relative paths (m4b-tool merge my-audio-books/an-audio-book --output-file="merged.m4b"
  • Prevent using absolute paths (starting with /)
  • Prevent traversing directories with ../

More details

I guess, that the most important part of this problem is, that you have to mount the local volume into the docker image correctly - otherwise it won't be accessable. If your current directory is /home/sandreas/audiobooks use the following alias command:

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

running m4b-tool resolves to:

// mapping: /home/sandreas/audiobooks => /mnt
docker run -it --rm -u sandreas:sandreas -v "/home/sandreas/audiobooks":/mnt m4b-tool

The docker image is configured to change into the directory /mnt by default - this means, that patterns like

m4b-tool merge an-audio-book
// /mnt/an-audio-book resolves to /mnt/an-audio-book and it does exist
// because it is a mounted directory within /mnt

will work, but

m4b-tool merge ../other-audiobooks

// /mnt/../other-audiobooks resolves to /other-audiobooks and it does not exist
// because it is not a mounted directory within /mnt

won't work, because the upper directory is not mounted into the image - like described in the notes:

Note: If you use the alias above, keep in mind that you cannot use absolute paths (e.g. /tmp/data/audiobooks/harry potter 1) or symlinks. You must change into the directory and use relative paths (e.g. cd /tmp/data && m4b-tool merge "audiobooks/harry potter 1" --output-file harry.m4b)

If you would like to use absolute paths, you could to the following:

docker run -it --rm -u $(id -u):$(id -g) -v "/absolute/path":/mnt m4b-tool merge /mnt/dir/in/absolute/path

But i would recommend to just keep the relative part of the directory and use the alias described in the documentation.

@MrTechGadget
Copy link

MrTechGadget commented Jan 20, 2020 via email

@tennyson-mccalla
Copy link

Having this problem right now. Nothing I saw above seems to solve it. I want to resolve both of these issues:

Your ffmpeg version cannot produce top quality aac using encoder aac instead of libfdk_aac
cannot read metadata, file does not exist

Right now I'm in my ~/Downloads directory and the files I'm trying to merge are in the ~/Downloads/Genre/Author/Title directory. When I try to run m4b-tool merge "Genre/Author/Title/" --output-file="Title.m4b" I immediately get back:

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

So I use sudo to overcome the permissions issue (though I've tried following this to some extent) and run sudo m4b-tool merge "Genre/Author/Title/" --output-file="Title.m4b" which is when I get:

Your ffmpeg version cannot produce top quality aac using encoder aac instead of libfdk_aac
cannot read metadata, file  does not exist

Is there anything I can do from here @sandreas ? Am I even in the right place to run these relative path commands? Should I be deeper in?

@sandreas
Copy link
Owner

sandreas commented Mar 21, 2020

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

You have to start the docker daemon - it seems that it is not running

Your ffmpeg version cannot produce top quality aac using encoder aac instead of libfdk_aac
cannot read metadata, file does not exist

Seems that you did not create the alias (alias m4b-tool="docker run...") and you installed m4b-tool on your host system

@tennyson-mccalla
Copy link

tennyson-mccalla commented Mar 21, 2020

You have to start the docker daemon - it seems that it is not running

Hmm... running systemctl status docker shows that the docker service is running. I stopped it and then ran sudo dockerd it looks normal (I haven't retried creating the m4b yet though).

Seems that you did not create the alias (alias m4b-tool="docker run...")...

No, definitely did that. From my command history:

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

and you installed m4b-tool on your host system

That could definitely be the case. I started with the Ubuntu instructions before I went back and did the docker ones. Going to retry the merge command though now that I've got dockerd going.

EDIT: Same errors.

EDIT 2: changed the alias command a bit to:
alias m4b-tool='sudo docker run -it --rm -u $(id -u):$(id -g) -v "$(pwd)":/mnt m4b-tool'

This eliminated the first issue and now only leaves the cannot read metadata, file does not exist problem.

@sandreas
Copy link
Owner

This eliminated the first issue and now only leaves the cannot read metadata, file does not exist problem.

I think that there is a permission problem... dockerd is a service/daemon that can be controlled via the docker command line tool, which by default access the local host.

Running sudo just to get rid of error messages is not always an expedient solution. Perhaps you ran something via sudo that changed the permissions of dockerd internals and now you must run everything as sudo, so that it is still working.

Under the hood the m4b-tool alias does the following:

  • runs a container based on the image tagged m4b-tool and removed it after the run: run -it --rm
  • maps the run context to the current user and group: -u $(id -u):$(id -g)
  • mounts the current directory into the docker image as /mnt: -v "$(pwd)":/mnt

It might be a problem of m4b-tool but on all my systems i do not require a sudo to run m4b-tool on docker...

@tennyson-mccalla
Copy link

tennyson-mccalla commented Mar 22, 2020

I didn’t have any docker related stuff on this machine prior to this so I’m willing to bet that there might’ve been something up with that installation. I can’t do (and from the beginning haven’t been able to do) anything with docker without sudo.

I got docker via apt get docker, and when that didn’t work to allow me to complete the docker related commands, apt get docker.io. Searching around for solutions to the problem have involved logging out and logging in.

I think I’ll try and start over with this docker installation.

@sandreas
Copy link
Owner

From my install script (no guarantees...):

## docker (Community Edition)
dpkg -s "docker-ce" &> /dev/null
if [ "$?" -ne "0" ]; then
        curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
        sudo add-apt-repository \
           "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
           $(lsb_release -cs) \
           stable"

        sudo apt -y purge docker docker-engine docker.io
        sudo apt -y update
        sudo apt -y install docker-ce
        sudo groupadd docker
        sudo usermod -aG docker "$USER"
  sudo systemctl enable docker
  sudo systemctl start docker
fi

## docker-compose
command -v docker-compose &> /dev/null || (sudo wget "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -O /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose)

@tennyson-mccalla
Copy link

Well, after a reboot things with docker at least seem to be working a bit better. I no longer have to use sudo to get things done. I can call docker run hello-world without any permissions problems. The group docker comes up when I run groups.

After ensuring that the docker service was running I then went to check my aliases for this session. The alias from last time was no longer there so I changed directory to ~/Downloads, ran alias m4b-tool='docker run -it --rm -u $(id -u):$(id -g) -v "$(pwd)":/mnt m4b-tool' and tried m4b-tool merge "Genre/Author/Title/" --output-file="Title.m4b". I got back:

cannot read metadata, file does not exist

The mp3 files I'm trying to merge into an m4b are all in ~/Downloads/Genre/Author/Title/ and I still have no idea what metadata file it's looking for or what else might be wrong. :-/

@MrTechGadget
Copy link

MrTechGadget commented Mar 22, 2020 via email

@tennyson-mccalla
Copy link

@MrTechGadget , yeah I saw your post above and now I'm thinking of just trying the same thing.

I've unaliased the m4b-tool command and I tried just running it but I still get the same original errors I was getting when I started.

Your ffmpeg version cannot produce top quality aac using encoder aac instead of libfdk_aac
cannot read metadata, file does not exist

I feel like I do have libfdk_aac (I don't know how to prove that I do or how to activate it during the process even if I wanted to) and the bigger problem of the metadata file remains.

@sandreas
Copy link
Owner

Well this seems to be something i should take a look at... I'll reopen the ticket and take a look, unfortunately I'm not able to do this in the next days.

@sandreas sandreas reopened this Mar 23, 2020
@tennyson-mccalla
Copy link

Thanks @sandreas . And feel free to take your time on this. I’m not going anywhere for a while 😅

@sandreas
Copy link
Owner

sandreas commented Jun 8, 2020

Ok, this one should be fixed with the latest Dockerfile and the latest changes. If not, please feel free to reopen and please provide --debug output (e.g. m4b-tool merge --debug ...)

@sandreas sandreas closed this as completed Jun 8, 2020
@TheFlath
Copy link

TheFlath commented Feb 3, 2021

So im running the tool dockerised and its version is m4b-tool v.0.4.2

I too am getting the cannot read metadata, file does not exist

My structure is /media/audio_books/BookFolders and i am CDing into /media and running m4b-tool merge "/audio_books/Hamilton" --output-file Hamilton.m4b

i've tried it without the / in front of audio_books, i've tried running it from with /media/audio_books and dropping that from the merge command as well, i've tried it with --output="Hamilton.m4b" as well as without quotes but with the =.

ran debug with it and here is the output

ffmpeg -hide_banner -codecs determine highest available audio codec + == load input files == cannot read metadata, file does not exist trace: #0 phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/MergeCommand.php(518): M4bTool\Command\AbstractCommand->readFileMetaData(Object(SplFileInfo)) #1 phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/MergeCommand.php(472): M4bTool\Command\MergeCommand->loadInputMetadataFromFirstFile() #2 phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/MergeCommand.php(362): M4bTool\Command\MergeCommand->processInputFiles()#3 phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/MergeCommand.php(194): M4bTool\Command\MergeCommand->processFiles(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #4 phar:///usr/local/bin/m4b-tool/vendor/symfony/console/Command/Command.php(255): M4bTool\Command\MergeCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #5 phar:///usr/local/bin/m4b-tool/vendor/symfony/console/Application.php(908): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #6 phar:///usr/local/bin/m4b-tool/vendor/symfony/console/Application.php(269): Symfony\Component\Console\Application->doRunCommand(Object(M4bTool\Command\MergeCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #7 phar:///usr/local/bin/m4b-tool/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #8 phar:///usr/local/bin/m4b-tool/bin/m4b-tool.php(32): Symfony\Component\Console\Application->run() #9 /usr/local/bin/m4b-tool(10): require('phar:///usr/loc...') #10 {main}

would love some input on what im doing wrong.

@sandreas
Copy link
Owner

sandreas commented Feb 4, 2021

Please check with the latest pre-release, it should be fixed there.

@TheFlath
Copy link

TheFlath commented Feb 10, 2021

Now i am getting

Could not detect length for file 01-finished.m4b, output 'sh: 1: exec: mp4info: not found ' does not contain a valid length value

Current version comes out as m4b-tool latest-127-gb61f0f8

In both cases, it is creating a subfolder called Book-tmpfiles and fills it with each file converted to an M4B, but then it errors out

@sandreas
Copy link
Owner

This is strange. The mp4info binary dependency is missing, but if you are using docker, this should not be the case because all dependencies are installed in the docker image. I need more info about your environment... which linux are you using and how is it possible that mp4info is not available. Please check, that you did not install m4b-tool while also having the docker aliased and these two are interfering...

@TheFlath
Copy link

Maybe something to do with this

`user@server:~$ sudo apt install ffmpeg mp4v2-utils fdkaac php-cli php-intl php-json php-mbstring php-xml [sudo] password for user: Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mp4v2-utils is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'mp4v2-utils' has no installation candidate`

I tried the docker version but kept getting hot with some error about time or date on line ninety something. I don't recall exactly but I can reproduce when I'm back at my machine.

For now I went with the local install on Ubuntu. Version 20.02 LTS

@TheFlath
Copy link

So i went ahead and followed some instructions i found here in regards to getting mp4-utils loaded.

yermak's instructions
wget http://archive.ubuntu.com/ubuntu/pool/universe/m/mp4v2/libmp4v2-2_2.0.0~dfsg0-6_amd64.deb wget http://archive.ubuntu.com/ubuntu/pool/universe/m/mp4v2/mp4v2-utils_2.0.0~dfsg0-6_amd64.deb dpkg -i libmp4v2-2_2.0.0~dfsg0-6_amd64.deb dpkg -i mp4v2-utils_2.0.0~dfsg0-6_amd64.deb

and it looks like things are working fine.

I will see about reproducing the error i got when trying to run it in docker.

@archisman-panigrahi
Copy link

I am using it in Manjaro from the AUR (without docker).

I found that if I use the command

m4b-tool merge "audiobook-directory" --output-file="bookname.m4b"

I get the error cannot read metadata, file does not exist.

If I instead use

m4b-tool merge audiobook-directory --output-file="bookname.m4b"

then there are no errors 😀

@sandreas
Copy link
Owner

Nice find. I'll take a look on this, as soon as I am not as busy any more... thank you.

@sandreas sandreas reopened this Jul 21, 2021
@driedell
Copy link

Possible solution:

I was getting the "cannot read metadata, file does not exist" error when running this inside a Ubuntu VM. I had attached the .mp3 files as a shared folder between my host PC and my VM. After I copied the .mp3's to the desktop of my VM, I was able to run the merge command. Seems like it was just having trouble accessing the shared folder.

As a side note, is there a size cutoff or a file-count cutoff? The first time I ran m4b-tool to merge 56 .mp3's into a .m4b it only did the first 40 of them.

@Sesselmann
Copy link

Hi,
it appears that I'm encountering the same problem (in Windows -> but utilizing Docker):

cannot read metadata, file does not exist >

using "Git for Windows" i used the bash console for downloding/building the container:
git clone https://github.com/sandreas/m4b-tool.git
docker build . -t m4b-tool

the definition of the alias was modified (so that it works) to:
alias m4b-tool='winpty docker run -it --rm -u $(id -u):$(id -g) -v "$(pwd)":/mnt m4b-tool'

after cd'ing to the directory "/to/where/I/want" (which has the subfolder "test" of the audiobook that contains the mp3s I get the error below (eventhough m4b-tool --version will give me m4b-tool v.0.4.2)

$ m4b-tool --debug merge "test" --output-file="out.m4b"
ffmpeg -hide_banner -codecs
PHP Warning: touch(): Unable to create file m4b-tool.log because Permission denied in phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/AbstractCommand.php on line 221
Debug file m4b-tool.log is not writable
PHP Warning: file_put_contents(): Filename cannot be empty in phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/AbstractCommand.php on line 228
determine highest available audio codec
== load input files ==
cannot read metadata, file does not exist
trace:
#0 phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/MergeCommand.php(518): M4bTool\Command\AbstractCommand->readFileMetaData()
#1 phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/MergeCommand.php(472): M4bTool\Command\MergeCommand->loadInputMetadataFromFirstFile()
#2 phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/MergeCommand.php(362): M4bTool\Command\MergeCommand->processInputFiles()
#3 phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/MergeCommand.php(194): M4bTool\Command\MergeCommand->processFiles()
#4 phar:///usr/local/bin/m4b-tool/vendor/symfony/console/Command/Command.php(255): M4bTool\Command\MergeCommand->execute()
#5 phar:///usr/local/bin/m4b-tool/vendor/symfony/console/Application.php(908):Symfony\Component\Console\Command\Command->run()
#6 phar:///usr/local/bin/m4b-tool/vendor/symfony/console/Application.php(269):Symfony\Component\Console\Application->doRunCommand()
#7 phar:///usr/local/bin/m4b-tool/vendor/symfony/console/Application.php(145):Symfony\Component\Console\Application->doRun()
#8 phar:///usr/local/bin/m4b-tool/bin/m4b-tool.php(32): Symfony\Component\Console\Application->run()
#9 /usr/local/bin/m4b-tool(10): require('phar:///usr/loc...')
#10 {main}
an error occured, that has not been caught:
Array
(
[type] => 2
[message] => file_put_contents(): Filename cannot be empty
[file] => phar:///usr/local/bin/m4b-tool/src/library/M4bTool/Command/Abstra
ctCommand.php
[line] => 228
)

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

8 participants