You are not logged in.

#1 2017-01-15 09:59:04

Kino
Member
From: Stockport, UK
Registered: 2016-04-30
Posts: 109

Converting m4b audiobooks to mp3 [solved]

Hi,

I'm trying to convert some m4b audio book files to mp3 format.

I was able to do this when #! was the operating system and I had a bash script which perforned the task perfectly.

Now I have upgraded to BL my script no longer works and I get no error messages of any kind.

The script is:

#!/bin/bash

# m4bronto
## -------- Usage: ./m4bronto file.m4b ---------------##
# Splice m4b audiobook to mp4 files by chapters
# I need a newer ffmpeg from 2014 at least I guess
# bronto 2015
# Thanks to izabera from freenode.

#     Chapter #0:0: start 0.000000, end 1290.013333
#       first   _     _     start    _     end

while [ $# -gt 0 ]; do

 /usr/bin/ffmpeg -i "$1" 2> tmp.txt

while read -r first _ _ start _ end; do
  if [[ $first = Chapter ]]; then
    read  # discard line with Metadata:
    read _ _ chapter
 #original
#    /usr/bin/ffmpeg -i "$1" -ss "${start%?}" -to "$end" -acodec copy "$chapter.mp4" </dev/null
   /usr/bin/ffmpeg -vsync 2 -i "$1" -ss "${start%?}" -to "$end" -vn -ar 44100 -ac 2 -ab 128k  -f mp3 "$chapter.mp3" </dev/null

fi
done <tmp.txt

rm tmp.txt

shift
done

I was able to find a python script which supposedly does the same thing but when I try to run that I get the error:

ImportError: No module named libmp4v2

I thought maybe this module may be missing so I looked in Synaptic and there is a libmp4v2-2 which I installed but changing the references in the script from libmp4v2 to libmp4v2-2 doesn't work.

Can anybody help?

Last edited by Kino (2017-01-15 10:42:05)

Offline

#2 2017-01-15 10:04:16

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,218
Website

Re: Converting m4b audiobooks to mp3 [solved]

Try to add 'set -x' at the start of the script for debugging.
http://tldp.org/LDP/Bash-Beginners-Guid … 02_03.html

Last edited by brontosaurusrex (2017-01-15 10:07:19)

Offline

#3 2017-01-15 10:38:01

Kino
Member
From: Stockport, UK
Registered: 2016-04-30
Posts: 109

Re: Converting m4b audiobooks to mp3 [solved]

Well, that certainly had an effect:

+ '[' 1 -gt 0 ']'
+ /usr/bin/ffmpeg -i twine.m4b
+ read -r first _ _ start _ end
+ [[ ffmpeg = Chapter ]]
+ read -r first _ _ start _ end
+ [[ built = Chapter ]]
+ read -r first _ _ start _ end
+ [[ configuration: = Chapter ]]
+ read -r first _ _ start _ end
+ [[ WARNING: = Chapter ]]
+ read -r first _ _ start _ end
+ [[ avutil = Chapter ]]
+ read -r first _ _ start _ end
+ [[ avcodec = Chapter ]]
+ read -r first _ _ start _ end
+ [[ avformat = Chapter ]]
+ read -r first _ _ start _ end
+ [[ avdevice = Chapter ]]
+ read -r first _ _ start _ end
+ [[ avfilter = Chapter ]]
+ read -r first _ _ start _ end
+ [[ avresample = Chapter ]]
+ read -r first _ _ start _ end
+ [[ swscale = Chapter ]]
+ read -r first _ _ start _ end
+ [[ swresample = Chapter ]]
+ read -r first _ _ start _ end
+ [[ postproc = Chapter ]]
+ read -r first _ _ start _ end
+ [[ libavutil = Chapter ]]
+ read -r first _ _ start _ end
+ [[ libavcodec = Chapter ]]
+ read -r first _ _ start _ end
+ [[ libavformat = Chapter ]]
+ read -r first _ _ start _ end
+ [[ libavdevice = Chapter ]]
+ read -r first _ _ start _ end
+ [[ libavfilter = Chapter ]]
+ read -r first _ _ start _ end
+ [[ libavresample = Chapter ]]
+ read -r first _ _ start _ end
+ [[ libswscale = Chapter ]]
+ read -r first _ _ start _ end
+ [[ libswresample = Chapter ]]
+ read -r first _ _ start _ end
+ [[ libpostproc = Chapter ]]
+ read -r first _ _ start _ end
+ [[ [mov,mp4,m4a,3gp,3g2,mj2 = Chapter ]]
+ read -r first _ _ start _ end
+ [[ Input = Chapter ]]
+ read -r first _ _ start _ end
+ [[ Metadata: = Chapter ]]
+ read -r first _ _ start _ end
+ [[ major_brand = Chapter ]]
+ read -r first _ _ start _ end
+ [[ minor_version = Chapter ]]
+ read -r first _ _ start _ end
+ [[ compatible_brands: = Chapter ]]
+ read -r first _ _ start _ end
+ [[ creation_time = Chapter ]]
+ read -r first _ _ start _ end
+ [[ title = Chapter ]]
+ read -r first _ _ start _ end
+ [[ artist = Chapter ]]
+ read -r first _ _ start _ end
+ [[ album = Chapter ]]
+ read -r first _ _ start _ end
+ [[ grouping = Chapter ]]
+ read -r first _ _ start _ end
+ [[ genre = Chapter ]]
+ read -r first _ _ start _ end
+ [[ track = Chapter ]]
+ read -r first _ _ start _ end
+ [[ date = Chapter ]]
+ read -r first _ _ start _ end
+ [[ compilation = Chapter ]]
+ read -r first _ _ start _ end
+ [[ gapless_playback: = Chapter ]]
+ read -r first _ _ start _ end
+ [[ encoder = Chapter ]]
+ read -r first _ _ start _ end
+ [[ iTunSMPB = Chapter ]]
+ read -r first _ _ start _ end
+ [[ iTunNORM = Chapter ]]
+ read -r first _ _ start _ end
+ [[ Duration: = Chapter ]]
+ read -r first _ _ start _ end
+ [[ Stream = Chapter ]]
+ read -r first _ _ start _ end
+ [[ Metadata: = Chapter ]]
+ read -r first _ _ start _ end
+ [[ creation_time = Chapter ]]
+ read -r first _ _ start _ end
+ [[ Stream = Chapter ]]
+ read -r first _ _ start _ end
+ [[ At = Chapter ]]
+ read -r first _ _ start _ end
+ rm tmp.txt
+ shift
+ '[' 0 -gt 0 ']'

But it did not convert the file.

Maybe there are no chapters???

Offline

#4 2017-01-15 10:41:44

Kino
Member
From: Stockport, UK
Registered: 2016-04-30
Posts: 109

Re: Converting m4b audiobooks to mp3 [solved]

I went back to a file I converted last year and the script worked ok.

It does seem that the m4b files I'm trying to convert don't have chapters so I'll have to try something else.

Thanks for your help.

Offline

#5 2017-01-15 16:36:59

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,218
Website

Re: Converting m4b audiobooks to mp3 [solved]

Kino wrote:

don't have chapters so I'll have to try something else.

Another thing: check that tmp.txt.

Offline

Board footer

Powered by FluxBB