Friday, December 27, 2013

Converting Audio Books to MP3 files - FIXED!

I have mentioned this previously, but downloaded some audio books in M4B format from Hay House.  While I haven't tried playing these on my phone, generally try to keep them all in one spot, the phone.

Previously had converted the files to one single MP3, but this is somewhat unwieldy in terms of listening to smaller chunks at a time.  When listening to longer books it's easier to remember by chapter than time (at least for me).

CAUTION:  Might want to skim, some things are a little "techie".

Came across this forum which gave some easy (supposedly) detailed steps to follow.
  1. Download Python 2.7 and install to directory of your choice.
  2. The 'PATH' means the directory, where the Python-executable is stored (in my case it was the 'Python 2.7' dir created on Hard drive (during install).
  3. Download 'ffmpeg.exe' from here this more current link (for example, other sites exist) and put it in the same directory as the Python-executable, i.e. the 'PATH'.
  4. Put m4b.py into any directory, which has enough space for the .mp3-output files (of course, as valekhz points out you may change the output-dir by editing the .py file, but I wouldn't dare, never having come close to coding such things...)
  5. Drag & drop m4b file onto the .py-file, wait (depending on CPU-power), find the new file(s) in a new subdirectory, called the same as the m4b...

My experiences doing this:

  • I already have python installed, Check one!
  • Had to edit the Path parameter to include python directory (in my case C:\Python27)
  • Downloaded the 32 bit and 64 bit versions from altered link shown above
  • Extracted 64 bit version of ffmpeg.exe into Python27 directory
  • Downloaded libmp4v2 and extracted into Python27 directory
  • Download converter script and extracted both .py files to Python27 directory
  • Dragged and dropped one of the m4b files and did as it said, created a new directory, with one mp3 file in it, not split out, but in a temp directory signifying possibly not done?!
  • Deleted output folder
  • Unzipped 32 bit version of ffmpeg.exe into Python27 directory, overwriting 64 bit version
  • From a dos prompt ran the command: m4b.py selfesteem.m4b
  • Output following error

C:\Python27>m4b.py selfesteem.m4b
INFO: Loading meta data...
INFO: Found 3 chapter(s).
INFO: Encoding audio book...
INFO: Splitting chapter  1/ 3 '01 Introduction'...
ERROR: An error occurred while splitting file.
  Command: C:\Python27\ffmpeg.exe -y -acodec copy -t 236.493 -ss 0.0 -i C:\Pytho
n27\selfesteem\temp\selfesteem.mp3 C:\Python27\selfesteem\01 Introduction.mp3
  Return code: 1
  Output: --->
ffmpeg version N-59275-g9b195dd Copyright (c) 2000-2013 the FFmpeg developers
  built on Dec 21 2013 22:01:05 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 58.101 / 52. 58.101
  libavcodec     55. 45.103 / 55. 45.103
  libavformat    55. 22.100 / 55. 22.100
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     4.  0.100 /  4.  0.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Unknown decoder 'copy'
  • Didn't know exactly what to do so kept reading the thread and they pointed to something stating that the command line arguments were re-ordered....  hummm
  • Downloaded latest version of script (0.5)
  • Tried, still gave same error
  • Found ffmpeg command within m4b.py file
  • Typed ffmpeg -h (from C:\Python27 directory) to get order of arguments
  • Went through existing command, from error above, with the order that they should be, by searching results of ffmpeg -h and trying till got it right
  • For this starting point, which didn't work:
ffmpeg -y -acodec copy -t 236.493 -ss 0.0 -i C:\Python27\selfesteem\temp\selfesteem.mp3 C:\Python27\selfesteem\_tmp_1.mp3
  • Wound up with this as a working command
ffmpeg -t 236.493 -ss 0.0 -i C:\Python27\selfesteem\temp\selfesteem.mp3 -y -acodec copy C:\Python27\selfesteem\_tmp_1.mp3
  • Notice how everything is the same but reordered. This worked.. YAY
  • Using windows explorer (2 of them), dragged the Audio Book (m4b file) onto m4b.py and it converted as it should.
  • In m4b.py, this is what was changed:
# The pound symbol denotes a comment so that line is not used and informational
#split_cmd = '%(ffmpeg)s -y -acodec copy -t %(duration)s -ss %(start)s -i %(outfile)s %(infile)s'
split_cmd = '%(ffmpeg)s -t %(duration)s -ss %(start)s -i %(outfile)s -y -acodec copy %(infile)s'

Now can convert all these audio books, some woo-woo, some not.

Will be uploading this soon as can get Sprint internet service as code repository is on my desktop (managed via google of course).

No comments:

Post a Comment