aax audiobooks to mp3 and splitting them into parts python

Viewed 193

I would like to write a tool for audiobooks, that is doing mainly the following:

  • convert aax to mp3 including metadata
  • put the mp3 in a database (probably mongo DB)
  • compare the information with a database (do you know any?)
  • split the mp3 into parts (provided by database mentioned before)

The main reason is that I'm sick of different providers of audiobooks and I want to have them in my own library. Therefore I need a database for audiobooks, preferably in many languages. I guess the hardest part is splitting the mp3 into parts provided by the database (I still need to find). Because the parts might be different and you know there is sometimes stuff like "Welcome to audible" and whatsoever. So do you have any idea where I can find this database?

1 Answers

To get chapters in an audiobook you can use:

ffprobe -i file.aac -print_format json -show_chapters -loglevel error

This gives you the metadata including start and end times. e.g.

{'id': 126,
  'time_base': '1/22050',
  'start': 1330963456,
  'start_time': '60361.154467',
  'end': 1336697460,
  'end_time': '60621.200000',
  'tags': {'title': 'Chapter 127'}
},

You can then extract these individually and convert them into mp3 files with ffmpeg using the -ss (start) and -to (end) commands.

Note: I am currently in the process of tidying up an app which splits audiable books into chapters, such that I can listen to them on my Garmin watch when running.

Related