Giter VIP home page Giter VIP logo

Comments (18)

sandreas avatar sandreas commented on May 30, 2024 1

Would "# import all formats" include opf?

Sure, import is easy. It already works, so there is nothing left to do.

from m4b-tool.

sandreas avatar sandreas commented on May 30, 2024

For the cover you could use
mp4art --extract input.m4b or ffmpeg -i input.m4b -an -vcodec copy cover.jpg

For the metadata extraction you could do a
ffmpeg -i audiobook.mp4 -f ffmetadata ffmetadata.txt

Since m4b-tool is not meant to wrap all possible ffmpeg features but only provide an easy interface to audiobook functions, i try to keep the merge and the split command in sync. So split creates cover.jpg, description.txt and i plan to integrate the creation of ffmetadata.txt for other metadata while merge command is taking exactly these files to enrich metadata when merging.

metadata.opf output for split is not planned, since this is a pretty complex format and i would prefer implementing more generic features instead - especially because it would take much time to do it right.

I also thought about a generate-chapters command to get only the chapters out of mp3 files, but unfortunately the length detection of ffmpeg is not reliable enough to do this with mp3 files - you have to convert the files first and then detect the length of m4b with mp4info. So because the conversion has to be done in every case, it would not save much time over a full merge process.

The next version of m4b-tool does already support ffmetadata.txt loading in merge command and perhaps i will implement ffmetadata.txt extraction in split, if i find the time... example content of ffmetadata.txt would be:

;FFMETADATA1
major_brand=isom
minor_version=512
compatible_brands=isomiso2mp41
title=A title
artist=An Artist
composer=A composer
album=An Album
date=2011
description=A description
comment=A comment
encoder=Lavf56.40.101
description=this is a description \
with "multiple lines" \
>> and special chars like €€€ and äöüß in it
genre=Hörbuch
encoder=Lavf58.25.100
[CHAPTER]
TIMEBASE=1/1000
START=0
END=11443
title=001
[CHAPTER]
TIMEBASE=1/1000
START=11443
END=132753
title=002
[CHAPTER]
TIMEBASE=1/1000
START=132753
END=1203111
title=003
[CHAPTER]
TIMEBASE=1/1000
START=1203111
END=1725444
title=004
[CHAPTER]
TIMEBASE=1/1000
START=1725444
END=1863084
title=005

from m4b-tool.

danrneal avatar danrneal commented on May 30, 2024

Thanks! That covers extraction. Is there a way to import/embed cover.jpg and metadata? I know the merge command already does this but merge also takes a long time since it is encoding/converting. Is there a way to only do the non-audio files part? (cover, description, metadata)

from m4b-tool.

sandreas avatar sandreas commented on May 30, 2024

Well, as i see your use case, perhaps it would indeed be nice to have something like this:

# export cover, description, chapters and ffmetadata
m4b-tool meta --export-cover --export-description --export-chapters --export-ffmetadata audiobook.m4b

# export all known formats
m4b-tool meta --export audiobook.m4b

# export only cover
m4b-tool meta --export-cover audiobook.m4b

and as counterpart

# import cover, description, chapters and ffmetadata
m4b-tool meta --import-cover --import-description --import-chapters --import-ffmetadata audiobook.m4b

# import all known formats
m4b-tool meta --import audiobook.m4b

# import only cover
m4b-tool meta --import-cover audiobook.m4b

I'll leave this issue open, since it requires some polishing, but i think, it could be a nice improvement.

from m4b-tool.

danrneal avatar danrneal commented on May 30, 2024

That would be awesome! Would "# import all formats" include opf? If not, that's okay, I might be able make a python script to make a ffmetadata from an opf.

from m4b-tool.

sandreas avatar sandreas commented on May 30, 2024

Here is a first alpha build (DO NOT USE ON PRODUCTION DATA) - including following options:

m4b-tool.tar.gz

# show metadata
m4b-tool meta audiobooks/an-audio-book.m4b

# import metadata from cover.jpg, description.txt, chapters.txt, ffmetadata.txt, metadata.opf
m4b-tool meta --auto-import audiobooks/an-audio-book.m4b

# export metadata to cover.jpg, description.txt, chapters.txt, ffmetadata.txt
m4b-tool meta --auto-export audiobooks/an-audio-book.m4b

This version already contains huge refactorings and might be unstable. Feedback would be great.

from m4b-tool.

danrneal avatar danrneal commented on May 30, 2024

Awesome! Thanks! I'll test either tonight or tomorrow some time!

from m4b-tool.

danrneal avatar danrneal commented on May 30, 2024

meta

Works like a charm

meta auto-export

chapters.txt works well
cover.jpg works well
description,.txt works well
ffmetadata.txt works well

meta auto-import

chapters.txt works well
cover.jpg doesn’t seem to import
ffmetadata.txt doesn’t seem to import
description.txt doesn’t seem to import
metadata.opf imports well but had an issue with adding “///” before semicolons (I’ve attached an example description.txt of the issue)

I haven’t tested the merge command yet, does that need to be tested too? Or is it unlikely for there to be an issue with that command?

description.txt

from m4b-tool.

danrneal avatar danrneal commented on May 30, 2024

Just finished testing the merge command with a folder that had multiple mp3s, metadata.opf, and cover.jpg. It seems to have worked, the cover, metadata (w/ description), and chapters are all correct.

from m4b-tool.

sandreas avatar sandreas commented on May 30, 2024

First of all many thanks for your testing effort.

cover.jpg doesn’t seem to import

Mmh, strange. Can't reproduce. My cover imports are working...

metadata.opf imports well but had an issue with adding “///” before semicolons (I’ve attached an example description.txt of the issue)

You mean \\\; - i tested it, for me it also worked as expected.

I haven’t tested the merge command yet, does that need to be tested too? Or is it unlikely for there to be an issue with that command?

There is some HUGE refactoring going on under the hood (moving code around). This will make many things easier and i can remove a lot of duplicated code - but it may also break some things, i hope in the end it will pay off.

ffmetadata.txt doesn’t seem to import
description.txt doesn’t seem to import

Ok, there were some issues with it. Here is a version with some fixes for description.txt.

DOWNLOAD m4b-tool.tar.gz

Keep in mind that there is an order of overwriting tags.
Tags will overwrite in this priority (from lowest to highest):

<existing tags of that file>
metadata.opf
ffmetadata.txt
description.txt
chapters.txt
<input parameters, e.g. --description>

So if you have a description in metadata.opf AND ffmetadata.txt AND description.txt, the one from description.txt will be used. And if you provide an input parameter --description=testing, this one will overwrite every other description.

from m4b-tool.

danrneal avatar danrneal commented on May 30, 2024

I've retested the cover (I will retest metadata later today as well)

Re: cover.jpg
When I auto-import, the cover is changed correctly on VLC. However, if I download the file to my android and play it (using Listen Audiobook player), the cover is the old cover. Furthermore, if I auto-export the corrected file, the old cover is exported. This is bizarre. It is as if it is storing both covers rather than overwriting.

from m4b-tool.

danrneal avatar danrneal commented on May 30, 2024

Finished testing the metadata files and they appear to be importing correctly. The issue of adding "\" before the semicolon appears to happen on export. When I run the 'meta' command, the output in the console is correct. When I export it, description.txt has "\" and ffmetadata has "\\\". Further more if I were to re-import the exported ffmetadata or description, it further compounds the issue as the next export will have "\\\\\\"

I tested the rest of the metadata files and commands and the rest appear to be working properly. This bug and the one above about cover.jpg are the only ones I've found in this build.

Thanks!!!

from m4b-tool.

sandreas avatar sandreas commented on May 30, 2024

Thank you for testing again.

This is bizarre. It is as if it is storing both covers rather than overwriting.

It is indeed possible that more than one cover is imported (mp4 / m4b does support more than one cover). Perhaps checking and removing the first cover if present before importing the new one solves the issue. I'll try that later.

When I export it, description.txt has \ and ffmetadata has \\\. Further more if I were to re-import the exported ffmetadata or description, it further compounds the issue as the next export will have \\\\\\

Ok, thats a good description, that should be reproducable. I'll take a look at it.
Thank you, too - especially for the star ;)

from m4b-tool.

sandreas avatar sandreas commented on May 30, 2024

Ok, heres a more sophisticated version, which at least fixes the \\\\\\-problem, changes structural things like parameter names and adds some new features:

m4b-tool.tar.gz

I will add the following documentation to the README.md, before i release next stable (which will still take a while):

meta (experimental)

With m4b-tool you can display, change, import and export specific metadata of one single m4b audiobook file. Since editing metadata is not the main goal of m4b-tool there might be a few things that do not work as expected, but for now this experimental feature is not beeing developed further, until major refactorings are finished.

Examples:

# show metadata of audiobook
m4b-tool meta my-audio-book.m4b

# import file based metadata (cover.jpg, description.txt, chapters.txt, etc.) and change album to "My Album"
m4b-tool meta --import-all --album="My Album" my-audio-book.m4b

# export file based metadata (cover.jpg, description.txt, chapters.txt, etc.)
m4b-tool meta --export-all my-audio-book.m4b

# remove metadata fields - this only works for the main fields, not for every possible field (!!)
m4b-tool meta --remove="album,albumArtist" my-audio-book.m4b

Reference

For all options, see m4b-tool meta --help:

Description:
  View and change metadata for a single file

Usage:
  meta [options] [--] <input>

Arguments:
  input                                          Input file or folder

Options:
      --logfile[=LOGFILE]                        file to log all output [default: ""]
      --debug                                    enable debug mode - sets verbosity to debug, logfile to m4b-tool.log and temporary encoded files are not deleted
  -f, --force                                    force overwrite of existing files
      --no-cache                                 clear cache completely before doing anything
      [...]
      --name[=NAME]                              custom name, otherwise the existing metadata will be used
      --sortname[=SORTNAME]                      custom sortname, that is used only for sorting
      --album[=ALBUM]                            custom album, otherwise the existing metadata for name will be used
      --sortalbum[=SORTALBUM]                    custom sortalbum, that is used only for sorting
      --artist[=ARTIST]                          custom artist, otherwise the existing metadata will be used
      --sortartist[=SORTARTIST]                  custom sortartist, that is used only for sorting
      --genre[=GENRE]                            custom genre, otherwise the existing metadata will be used
      --writer[=WRITER]                          custom writer, otherwise the existing metadata will be used
      --albumartist[=ALBUMARTIST]                custom albumartist, otherwise the existing metadata will be used
      --year[=YEAR]                              custom year, otherwise the existing metadata will be used
      --description[=DESCRIPTION]                custom short description, otherwise the existing metadata will be used
      --longdesc[=LONGDESC]                      custom long description, otherwise the existing metadata will be used
      --comment[=COMMENT]                        custom comment, otherwise the existing metadata will be used
      --copyright[=COPYRIGHT]                    custom copyright, otherwise the existing metadata will be used
      --encoded-by[=ENCODED-BY]                  custom encoded-by, otherwise the existing metadata will be used
      --cover[=COVER]                            custom cover, otherwise the existing metadata will be used
      --skip-cover                               skip extracting and embedding covers
      --series[=SERIES]                          custom series, this pseudo tag will be used to auto create sort order (e.g. Harry Potter or The Kingkiller Chronicles)
      --series-part[=SERIES-PART]                custom series part, this pseudo tag will be used to auto create sort order (e.g. 1 or 2.5)
      --fix-mime-type                            try to fix MIME-type (e.g. from video/mp4 to audio/mp4) - this is needed for some players to prevent an empty video window
      --import-all                               use all existing default tag sources to import metadata (e.g. cover.jpg, description.txt, chapters.txt, etc.)
      --import-cover[=IMPORT-COVER]              import cover cover file (e.g. cover.jpg) [default: false]
      --import-description[=IMPORT-DESCRIPTION]  import description from plaintext file (e.g. description.txt) [default: false]
      --import-ffmetadata[=IMPORT-FFMETADATA]    import metadata in ffmetadata1 format (e.g. ffmetadata.txt) [default: false]
      --import-opf[=IMPORT-OPF]                  import metadata from opf format (e.g. metadata.opf) [default: false]
      --import-chapters[=IMPORT-CHAPTERS]        import chapters from mp4v2 format (e.g. chapters.txt) [default: false]
      --export-all                               export all default tag sources as files (e.g. cover.jpg, description.txt, chapters.txt, etc.)
      --export-cover[=EXPORT-COVER]              export cover cover file (e.g. cover.jpg) [default: false]
      --export-description[=EXPORT-DESCRIPTION]  export description from plaintext file (e.g. description.txt) [default: false]
      --export-ffmetadata[=EXPORT-FFMETADATA]    export metadata in ffmetadata1 format (e.g. ffmetadata.txt) [default: false]
      --export-chapters[=EXPORT-CHAPTERS]        export chapters from mp4v2 format (e.g. chapters.txt) [default: false]
      --remove[=REMOVE]                          remove these tags (either comma separated --remove='title,album' or multiple usage '--remove=title --remove=album' (multiple values allowed)
  -h, --help                                     Display this help message
  -q, --quiet                                    Do not output any message
  -V, --version                                  Display this application version
      --ansi                                     Force ANSI output
      --no-ansi                                  Disable ANSI output
  -n, --no-interaction                           Do not ask any interactive question
  -v|vv|vvv, --verbose                           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

from m4b-tool.

danrneal avatar danrneal commented on May 30, 2024

meta --remove doesn't work for me. I tried "cover", "chapters", "album", and "album,albumArtist"
I'm not sure this command is needed since you could just import metadata with a blank field if you wanted to remove anything

Cover definitely adds a cover rather than replaces the existing cover since when I do mp4art --extract it extracts multiple covers. The merge command does not seem to have this issue since when I merge, all the covers get removed and replace with the correct cover.

mp4art --replace works for the covers though so it isn't that big of a deal.

from m4b-tool.

sandreas avatar sandreas commented on May 30, 2024

Thank you for your feedback and your testing.

meta --remove doesn't work for me. I'm not sure this command is needed...

Well, i think adding something should always imply that it can be removed too - I have to check and fix this even if this means I'm a stickler ;)

Cover definitely adds a cover rather than replaces the existing cover since when I do mp4art --extract it ...

This is a good hint... I will change the code to remove all covers before adding a new one, so the cover issue will be resolved. That should work for all commands then (merge and meta atm)

from m4b-tool.

sandreas avatar sandreas commented on May 30, 2024

next try: https://github.com/sandreas/m4b-tool/releases/tag/latest

  • cover problems should be fixed
  • removing tags should work for every tag now
  • only thing that did not work on my tests: If a cover is embedded, it is not showing up => its working now

from m4b-tool.

sandreas avatar sandreas commented on May 30, 2024

Ok, i think this issue can be closed now. If there is still something missing or open, feel free to reopen it.

from m4b-tool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.