IPB

Welcome Guest ( Log In | Register )

2 Pages V  < 1 2  
Reply to this topicStart new topic
M4B to MP3 (chapter separation), Converting M4B to multiple MP3s taking into account the M4B chapters
valekhz
post Dec 13 2010, 22:59
Post #26





Group: Members
Posts: 10
Joined: 4-December 10
Member No.: 86227



Had some time to figure out the Unicode problem today and it's only an issue on Windows. ffmpeg can't handle Unicode filenames on Windows but does it fine on other platforms. So to fix this I just had to work around it by feeding non-unicode filenames to ffmpeg then rename to the correct one.

Here's the new release (v0.4.2): download
  • Unicode support
  • Run the old version (without mp4v2) with --no-mp4v2. Note that this version can't parse all chapters and Unicode won't work.
  • Customize chapter filenames. (request by daleybox)
To get filenames like "Chapter 5 - Title.mp3" you can call the script like this:
CODE
python m4b.py --custom-name 'Chapter %(num)d - %(title)s' myfile.m4b

If you're not familiar with python formatting %(num)d will turn into the chapter number and %(title)s the chapter title. You can do more advanced formatting too, e.g. if you want "Chapter 05" instead you can use %(num)02d, and so on.
Go to the top of the page
+Quote Post
HydrogenNoobie
post Dec 13 2010, 23:37
Post #27





Group: Members
Posts: 7
Joined: 20-September 10
Member No.: 83999



Valekhz - I prefer no pre-pending of "Chapter nn" to the beginning of the filename. If you do prepend filenames with chapter numbers, perhaps there could be an option to enable / disable it?

daleybox - If for some reason valekhz does not implement the feature, or if you do not want to wait, there is a pretty easy workaround for you to try...
1) dump the filenames and creation timestamps of the files output by valekhz's m4b-converter into a text file sorted by time created (in Windows, this can be done with "dir /od > dir.txt" - even if they all display the same time to the minute - the OS knows which were created first to the second or better)
2) open this text file in Excel
3) use the "Concatenate" command in Excel to build a DOS command to do the renaming. I've done this for Windows, and I'm sure equivalent simple steps exist for other OS's. For example...
=CONCATENATE("copy """,A6,""" ""Chapter ",C6," - ",A6,"""")
where column A has the old file name, column C has the numbering you want to use
4) copy this row down for all the files, then copy the whole list of commands into a DOS batch file

With this approach, you can then rename or create copies with the new name for all the files at once. This approach is easy and flexible, and would prevent valekhz from then getting additional requests to support things like:
a) users with m4b files with a Preface or Forward or both asking to offset the first chapter by 1 or 2 (or more) files?
b) users with an audio book that is split into multiple m4b's with multiple chapters per m4b asking to offset so that the first file starts with Chapter Y?
c) users who prefer chapters in roman numerals asking for "chapter i" and "Chapter ii" instead of "Chapter 1" and "Chapter 2"
d) users whose audio players sorts / plays the files the order Chapter 1, 10, 11,12.....,19, 2, 20, 21....29, 3, 30, 31 asking to make the chapters two digits wide so they sort in the proper order
e) users who speak language X asking to add options to name files "Kapitel 1" or "Capítula 1" instead of "Chapter 1".
f) users who want the author and/or title added along with or instead the file name / chapter name.

While I prefer that the chapter number is not added to the file name, I can solve that myself. I'm just trying to think about the future in case there are enough people looking to split M4B files that it really matters.
Go to the top of the page
+Quote Post
HydrogenNoobie
post Dec 13 2010, 23:50
Post #28





Group: Members
Posts: 7
Joined: 20-September 10
Member No.: 83999



valekhz,
I hadn't seen your latest post when I posted. I will try your new file soon - thank you. No that I see your post - you can ignore mine. The Unicode support was a much bigger deal for me.

Thanks again for your work.
Go to the top of the page
+Quote Post
HydrogenNoobie
post Dec 14 2010, 06:33
Post #29





Group: Members
Posts: 7
Joined: 20-September 10
Member No.: 83999



Wow! I am both impressed and happy.
Not only does it process my files with special characters correctly, but you handled the chapter request very nicely. I am impressed with all the options of the command-line version. I also tried it on a file of size 15MB, and it worked there as well. I do have a couple findings....

1) I used it on several files, all with special characters. I didn't see any error messages or crashes, or any real problems at all.

2) I notice that sometimes both the Chinese characters and the Pinyin come out, and sometimes only the Pinyin. Is that due to the construction of the original m4b or something about the way m4b.py is reading it? Is there anything that can be done to get the Chinese characters all the time?

3) The question mark ("?") is not allowed as characters in file names, and the period "." is the delimiter between the base filename and the extension. I notice that "?"'s are removed, and sentences have the "." However, the characters used in Chinese writing are allowed as file names "?" and "。". This is not too important, but as a low-priority request - is there any chance to make use these characters when they appear in the chapter name rather than removing the "?" and having double "normal periods" in some file names? This might best be an option, as these characters may appear unusual to some users.

4) I notice that the special characters are not displayed properly by the "dir" command in Windows DOS command window, although they are displayed correctly in Windows Explorer. A note to other users: If anyone wants a text file with the filenames (which I use for importing these files into another program), one can browse the directory using Firefox, the copy-paste the file name list to a text file, remove the extra fields (size/timestamp/etc) to get just a list of files.

Thanks again for your great work.
Go to the top of the page
+Quote Post
daleybox
post Dec 14 2010, 14:19
Post #30





Group: Members
Posts: 2
Joined: 13-December 10
Member No.: 86470



Thanks so much for the chapter naming support, and it's great how it can be customized so others don't have to have it if they don't want! Thanks again so much, this is great!
Go to the top of the page
+Quote Post
valekhz
post Dec 14 2010, 20:37
Post #31





Group: Members
Posts: 10
Joined: 4-December 10
Member No.: 86227



QUOTE (HydrogenNoobie @ Dec 14 2010, 06:33) *

2. m4b.py just reads the chapters as constructed by the author so there's nothing the script could do differently to get the chinese characters.

3. "." is valid in filenames and those aren't filtered out. I won't add the question mark thing to the script because it's too specific for this particular case. However, it's really easy to make this change yourself: m4b.py Changes were made to line 2, 129 and 139. The actual replacement happens at line 139: .replace('?', '?') You can add more replace if you want to change more characters.

4. I have tried many times to get that to work but no success. Your firefox solution is good enough.

This post has been edited by valekhz: Dec 14 2010, 20:39
Go to the top of the page
+Quote Post
HydrogenNoobie
post Dec 17 2010, 05:43
Post #32





Group: Members
Posts: 7
Joined: 20-September 10
Member No.: 83999



Valekhz,

2. Ahh. I suspected that might be the case. I'm still happy that the majority of the chapters can be parsed.

3. I can understand the the question mark thing is too much of a special case. And yes - I was able to get my special case to work, thanks to the guidance you provided.

Finally, if you don't mind - one last question: Several of these files created by the m4B.py have the word / sentence that I want to hear, then 3-4 seconds of silence, then the same word / sentence again. (same as original m4b chapter) I actually only want the mp3 to contain the word / phrase once. Might you be able to make another .py file that takes an mp3 file in, measures the duration of the file, and simply saves only the 1st half under the same name (deleting 2nd half)? (FYI - I will then run this on all files in a given directory, and then clean up silences and the like with Audacity "Apply Chains" - but audacity doesn't seem to have batch splitting)

Sorry to ask you for something else after all you have done, but you seem to have the skills to do this 1000 times easier than I ever could.

Thank you
Go to the top of the page
+Quote Post
valekhz
post Dec 17 2010, 19:53
Post #33





Group: Members
Posts: 10
Joined: 4-December 10
Member No.: 86227



QUOTE (HydrogenNoobie @ Dec 17 2010, 05:43) *
Valekhz,

2. Ahh. I suspected that might be the case. I'm still happy that the majority of the chapters can be parsed.

3. I can understand the the question mark thing is too much of a special case. And yes - I was able to get my special case to work, thanks to the guidance you provided.

Finally, if you don't mind - one last question: Several of these files created by the m4B.py have the word / sentence that I want to hear, then 3-4 seconds of silence, then the same word / sentence again. (same as original m4b chapter) I actually only want the mp3 to contain the word / phrase once. Might you be able to make another .py file that takes an mp3 file in, measures the duration of the file, and simply saves only the 1st half under the same name (deleting 2nd half)? (FYI - I will then run this on all files in a given directory, and then clean up silences and the like with Audacity "Apply Chains" - but audacity doesn't seem to have batch splitting)

Sorry to ask you for something else after all you have done, but you seem to have the skills to do this 1000 times easier than I ever could.

Thank you

No problem. I made an addition to line 19: m4b_half.py. This will save the first half of each chapter so if you don't want to cut all chapters you should run the old version first and save the ones that shouldn't be cut then run this one.
Go to the top of the page
+Quote Post
HydrogenNoobie
post Dec 27 2010, 20:08
Post #34





Group: Members
Posts: 7
Joined: 20-September 10
Member No.: 83999



Valekhz,

I just wanted to say thank you one last time. I have been using m4b.py and m4b_half.py for a few days, and found that it really solves the hardest part of the problem I had been having. You wrote it to be flexible enough to solve the majority of my problems, and even allow me to make some minor tweaks on my own (I'm also replacing ":" with -" to be Windows/Dos compatible and "[" with "(" to be Anki compatible).

Thank you so much for your efforts.
Go to the top of the page
+Quote Post
valekhz
post Jan 3 2011, 16:55
Post #35





Group: Members
Posts: 10
Joined: 4-December 10
Member No.: 86227



No problem, I'm glad it worked.

I needed a few more features for myself so I'll release them as v0.5. Changes:
  • More advanced encoding options
  • Drop multiple m4b files onto m4b.py
I also cleaned up and simplified the code which means m4b_half and those modifications will need some changes. But you can safely skip this one if you already have the previous version and don't need the new features. The only thing left on my TODO is making the script work with more python versions than 2.7 but this has a low priority.
Go to the top of the page
+Quote Post
brian2090
post Feb 24 2011, 04:52
Post #36





Group: Members
Posts: 3
Joined: 23-May 05
Member No.: 22236



QUOTE (daleybox @ Dec 12 2010, 21:36) *
.... The script works well, however, when it extracts the chapters and names to mp3, I have no idea of what order they should have be in. Could there be an internal counter or something so that you would get something like "Chapter 1 - " prepended to the chapter title? Otherwise, the only way I see to figure out the order is to listen to each one and hope it starts with the chapter number...


You should try sorting the mp3 files listing by time and date created; the oldest file should be the first chapter, no? Just seems like that would work for you, then a rename batch could append the chapter index to the filename.


--------------------
Brian2090

*----====== "Are you [I]sure[/I] that's a candle?"
Go to the top of the page
+Quote Post
js2002
post Jul 28 2011, 12:57
Post #37





Group: Members
Posts: 3
Joined: 28-July 11
Member No.: 92615



QUOTE (valekhz @ Dec 4 2010, 01:22) *
If anyone is still interested I wrote a little python script to do this. You can find the git repository here: https://github.com/valekhz/m4b-converter. If you don't use git you can just download the python file here: https://github.com/valekhz/m4b-converter/raw/master/m4b.py.

You'll need python (only tested with 2.7 so far) and ffmpeg. Place the m4b.py somewhere and drag your *.m4b file onto m4b.py, or use the command line. There's a README in the git repository for more info on how to use it. I haven't been able to test that many .m4b files yet but those I've tried have worked great. I've tested it on Windows 7 and Ubuntu.

Basically it works by parsing the output of ffmpeg -i file.m4b to get the chapter data, encodes the audio and splits it based on the data from ffmpeg. Sorry if the code is a bit messy, haven't been coding in python for a while. smile.gif



Huh?

this is my log: access denied (its german here "zugriff verweigert")

D:\py>m4b.py -o ./doc --ffmpeg ./bin --encoder ./bin --ext mp3 --no-mp4v2 test.m
4b --debug
INFO: m4bsplit started.
DEBUG: Options:
ffmpeg: ./bin
custom_name: %(title)s
skip_encoding: False
filename: ['test.m4b']
encoder: ./bin
ext: mp3
encode_opts: -y -i %(infile)s -acodec libmp3lame -ar %(sample_rate)d -ab %(b
it_rate)dk %(outfile)s
output_dir: ./doc
debug: True
pipe_wav: False
no_mp4v2: True
INFO: Initiating script for file 'test.m4b'.
INFO: Loading metadata using ffmpeg...
DEBUG: Retrieving metadata from output of command: ./bin -i test.m4b
Traceback (most recent call last):
File "D:\py\m4b.py", line 337, in <module>
main()
File "D:\py\m4b.py", line 328, in main
chapters, sample_rate, bit_rate, metadata = load_metadata(args, log, filenam
e)
File "D:\py\m4b.py", line 205, in load_metadata
return ffmpeg_metadata(args, log, filename)
File "D:\py\m4b.py", line 143, in ffmpeg_metadata
ignore_errors=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "D:\py\m4b.py", line 44, in run_command
proc = subprocess.Popen(cmd, **kwargs)
File "C:\Python32\lib\subprocess.py", line 741, in __init__
restore_signals, start_new_session)
File "C:\Python32\lib\subprocess.py", line 960, in _execute_child
startupinfo)
WindowsError: [Error 5] Zugriff verweigert

D:\py>


this is the output without the no v2 parameter:

D:\py>m4b.py -o ./doc --ffmpeg ./bin --encoder ./bin --ext mp3 test.m4b --debug
INFO: m4bsplit started.
DEBUG: Options:
ffmpeg: ./bin
custom_name: %(title)s
skip_encoding: False
filename: ['test.m4b']
encoder: ./bin
ext: mp3
encode_opts: -y -i %(infile)s -acodec libmp3lame -ar %(sample_rate)d -ab %(b
it_rate)dk %(outfile)s
output_dir: ./doc
debug: True
pipe_wav: False
no_mp4v2: False
INFO: Initiating script for file 'test.m4b'.
INFO: Loading metadata using libmp4v2...
Traceback (most recent call last):
File "D:\py\m4b.py", line 337, in <module>
main()
File "D:\py\m4b.py", line 328, in main
chapters, sample_rate, bit_rate, metadata = load_metadata(args, log, filenam
e)
File "D:\py\m4b.py", line 208, in load_metadata
return mp4v2_metadata(filename)
File "D:\py\m4b.py", line 188, in mp4v2_metadata
from libmp4v2 import MP4File
ImportError: No module named libmp4v2

D:\py>

This post has been edited by js2002: Jul 28 2011, 12:59
Go to the top of the page
+Quote Post
js2002
post Jul 28 2011, 14:55
Post #38





Group: Members
Posts: 3
Joined: 28-July 11
Member No.: 92615



fixed 1 problem in line 44:

proc = subprocess.Popen("runas /user:Admin cmd.exe", **kwargs)

as admin i come little bit closer...
but then ist stops at:

INFO: Loading metadata using ffmpeg...
DEBUG: Retrieving metadata from output of command: ./bin -i test.m4b
Go to the top of the page
+Quote Post
alexf
post Aug 23 2011, 22:40
Post #39





Group: Members
Posts: 1
Joined: 23-August 11
Member No.: 93232



thanks to valekhz for creating this script smile.gif


This post has been edited by alexf: Aug 23 2011, 22:43
Go to the top of the page
+Quote Post
swavek
post Oct 15 2011, 18:58
Post #40





Group: Members
Posts: 1
Joined: 15-October 11
Member No.: 94405



First off, many thanks to valekhz for building this tool. There is only one other program out there that I found (Bigasoft Audio Converter), but it doesn't have command-line support and so this tool still reigns supreme.

In hopes that valekhz is still open to tweaking the tool, I ran into one problem. For some reason, the tool crashes on The Economist podcasts with this message:
Traceback (most recent call last):
File "C:\Programs\Python27\m4b.py", line 337, in <module>
main()
File "C:\Programs\Python27\m4b.py", line 334, in main
split(args, log, output_dir, encoded_file, chapters)
File "C:\Programs\Python27\m4b.py", line 290, in split
chapter_name = unicode(chapter_name, 'utf-8')
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: invalid start byte

Here is an example file I tried to split: http://dl.dropbox.com/u/19007038/13%20Inte...C%20The%20E.m4a
(I know it's an m4a extension, but the same issue happens on m4b's)

Thanks to valekhz or anyone else who can help with this!
Go to the top of the page
+Quote Post
ertdredge
post Oct 16 2011, 03:57
Post #41





Group: Members
Posts: 1
Joined: 16-October 11
Member No.: 94412



As with everyone who's posted, major props to valekhz for building and maintaining this.

I got this working on Mac (Snow Leopard 10.6) with some fiddling:
  • OS 10.6 comes with python 2.6 pre-installed, I had to upgrade python to 2.7.x
  • I used macports to install all the requirements
  • The check for 'darwin' compatibility was removed from libmp4v2.py sometime between v0.2 and v0.5, I added it back to get around the "NotImplementedError: O/S 'darwin' not supported":
    CODE
    elif sys.platform.startswith('darwin'):
        dll = ctypes.CDLL('libmp4v2.dylib')
  • LAME 3.98.2, the default version with macports was broken, I got "lame: output buffer too small" I had to downgrade to v3.98.0
  • I needed to manually add the mp4v2 location to DYLD_LIBRARY_PATH


Which all sums up to something like this:
  • Download Python 2.7.2 from python.org and install it
  • Add the code snippet, above, at line 16 to libmp4v2.py


...and then, open a fresh Terminal window (to pick up the new Python version that the Python installer adds to your path), and

CODE
sudo port install ffmpeg
sudo port install mp4v2
export DYLD_LIBRARY_PATH=/opt/local/lib
cd /tmp
curl -O http://trac.macports.org/export/38059/trunk/dports/audio/lame/Portfile
sudo port install


Then cd back to where you downloaded and unzipped valekhz-m4b-converter and do the expected

CODE
python m4b.py filename.m4a


Voila. You can add the export DYLD_LIBRARY_PATH=/opt/local/lib into your ~/.bash_profile for future convenience. Possibly you don't need to do all of this in OS 10.7 but I'm dragging my feet on the upgrade.

Thanks again, valekhz!

Go to the top of the page
+Quote Post
fyrebender360
post Nov 9 2011, 23:23
Post #42





Group: Members
Posts: 1
Joined: 9-November 11
Member No.: 95062



Absolutely brilliant!!!! Thanks for all the hard work valekhz.
Go to the top of the page
+Quote Post
Jaantat
post Jun 16 2012, 15:30
Post #43





Group: Members
Posts: 1
Joined: 16-June 12
Member No.: 100769



I tried all different versions but still it makes just one mp3 file sad.gif
Can someone help me out?
i can see that it reads the chapter names but it wont make multiple files

CODE
C:\Python27>python m4b.py --debug game.m4b
INFO: m4bsplit started.
DEBUG: Options:
ffmpeg: ffmpeg
custom_name: %(title)s
skip_encoding: False
filename: ['game.m4b']
encoder: ffmpeg
ext: mp3
encode_opts: -y -i %(infile)s -acodec libmp3lame -ar %(sample_rate)d -ab %(b
it_rate)dk %(outfile)s
output_dir:
debug: True
pipe_wav: False
no_mp4v2: False
INFO: Initiating script for file 'game.m4b'.
INFO: Loading metadata using libmp4v2...
INFO:
Metadata:
Chapters: 135
Bit rate: 64 kbit/s
Sampling freq: 22050 Hz
DEBUG:
Chapter data:
<Chapter Title="00 - Prologue 1", Start=0:00:00, End=0:10:00, Dura
tion=0:10:00>
<Chapter Title="Part 1.1", Start=0:10:00, End=0:20:00, Duration=0:10:00>
<Chapter Title="Part 1.2", Start=0:20:00, End=0:24:33.005000, Duration=0:04:33.0
05000>
-----------------------
-----------------------
<Chapter Title="Part 38.3", Start=16:09:59.963000, End=16:17:54.605000, Duration
=0:07:54.642000>
INFO: Encoding audio...
DEBUG: Encoding with command: ffmpeg -y -i game.m4b -acodec libmp3lame -ar 22050
-ab 64k game\temp\game.mp3
ffmpeg version N-41416-g718607b Copyright © 2000-2012 the FFmpeg developers
built on Jun 8 2012 12:46:19 with gcc 4.6.3
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass
--enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable
-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libope
njpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libth
eora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-
libvorbis --enable-libvpx --ena libavutil 51. 56.100 / 51. 56.100
libavcodec 54. 25.100 / 54. 25.100
libavformat 54. 6.101 / 54. 6.101
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 78.101 / 2. 78.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'game.m4b':
Metadata:
major_brand : M4A
minor_version : 0
compatible_brands: 3gp5isom
creation_time : 2011-04-30 13:52:34
genre : Audiobook
media_type : 2
encoder : Chapter and Verse V 1.4
title : 01 - A Game of Thrones - Part 1
artist : George R.R. Martin
album : A Game of Thrones
composer : George R.R. Martin
track : 1/2
Duration: 16:17:54.64, start: 0.000000, bitrate: 60 kb/s
Chapter #0.0: start 0.000000, end 600.000000
Metadata:
title : 00 - Prologue 1
Chapter #0.1: start 600.000000, end 1200.000000
Metadata:
title : Part 1.1
-----------------------------
-------------------------------
Metadata:
title : Part 38.1
Chapter #0.133: start 57600.000000, end 58200.000000
Metadata:
title : Part 38.2
Chapter #0.134: start 58200.000000, end 58674.642721
Metadata:
title : Part 38.3
Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, stereo, s16, 59
kb/s
Metadata:
creation_time : 2011-04-30 13:52:34
Stream #0:1(und): Subtitle: mov_text (text / 0x74786574)
Metadata:
creation_time : 2011-04-30 13:54:41
Output #0, mp3, to 'game\temp\game.mp3':
Metadata:
major_brand : M4A
minor_version : 0
compatible_brands: 3gp5isom
TDEN : 2011-04-30 13:52:34
TCON : Audiobook
media_type : 2
TRCK : 1/2
TIT2 : 01 - A Game of Thrones - Part 1
TPE1 : George R.R. Martin
TALB : A Game of Thrones
TCOM : George R.R. Martin
TSSE : Lavf54.6.101
Chapter #0.0: start 0.000000, end 600.000000
Metadata:
title : 00 - Prologue 1
Chapter #0.1: start 600.000000, end 1200.000000
Metadata:
title : Part 1.1
Chapter #0.2: start 1200.000000, end 1473.005442
Metadata:
title : Part 1.2
Chapter #0.3: start 1473.005442, end 1800.000000
------------------
-------------------
Metadata:
title : Part 38.2
Chapter #0.134: start 58200.000000, end 58674.642721
Metadata:
title : Part 38.3
Stream #0:0(und): Audio: mp3, 22050 Hz, stereo, s16, 64 kb/s
Metadata:
creation_time : 2011-04-30 13:52:34
Stream mapping:
Stream #0:0 -> #0:0 (aac -> libmp3lame)
Press [q] to stop, [?] for help
size= 458397kB time=16:17:54.65 bitrate= 64.0kbits/s
video:0kB audio:458396kB global headers:0kB muxing overhead 0.000119%
INFO: Splitting chapter 1/135 '00 - Prologue 1'...
DEBUG: Splitting with command: ffmpeg -y -acodec copy -t 600.0 -ss 0.0 -i game\t
emp\game.mp3 game\_tmp_1.mp3
ERROR:
An error occurred while splitting audio file.
Command: ffmpeg -y -acodec copy -t 600.0 -ss 0.0 -i game\temp\game.mp3 game\_t
mp_1.mp3
Return code: 1
Output: ---->
ffmpeg version N-41416-g718607b Copyright © 2000-2012 the FFmpeg developers
built on Jun 8 2012 12:46:19 with gcc 4.6.3
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass
--enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable
-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libope
njpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libth
eora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-
libvorbis --enable-libvpx --ena libavutil 51. 56.100 / 51. 56.100
libavcodec 54. 25.100 / 54. 25.100
libavformat 54. 6.101 / 54. 6.101
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 78.101 / 2. 78.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Unknown decoder 'copy'


This post has been edited by db1989: Jun 16 2012, 17:17
Reason for edit: Use [codebox] for large items, not [code].
Go to the top of the page
+Quote Post
cynepnaxa
post Jul 15 2012, 02:35
Post #44





Group: Members
Posts: 2
Joined: 15-July 12
Member No.: 101434



Many thanks to valekhz! Note for customers. Valekhz's script is working fine. If smtg not work follow instruction from begin or see run options.

On Ubuntu 12.04 you just run in terminal in any folder:

sudo apt-get install python2.7 ffmpeg libavcodec-extra-53 mp4v2-utils libmp4v2-dev libmp4v2-2 git
git clone https://github.com/valekhz/m4b-converter.git
cd ./m4b-converter
python m4b.py --no-mp4v2 PATH_TO_YOUR_M4B_FILE_ABSOLUTE_OR_RELATIVE_FROM_NEW_DIR_m4b-converter


QUOTE (swavek @ Oct 15 2011, 18:58) *
First off, many thanks to valekhz for building this tool. There is only one other program out there that I found (bigsoftasses Audio Converter), but it doesn't have command-line support and so this tool still reigns supreme.

In hopes that valekhz is still open to tweaking the tool, I ran into one problem. For some reason, the tool crashes on The Economist podcasts with this message:
Traceback (most recent call last):
File "C:\Programs\Python27\m4b.py", line 337, in <module>
main()
File "C:\Programs\Python27\m4b.py", line 334, in main
split(args, log, output_dir, encoded_file, chapters)
File "C:\Programs\Python27\m4b.py", line 290, in split
chapter_name = unicode(chapter_name, 'utf-8')
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: invalid start byte

Here is an example file I tried to split: http://dl.dropbox.com/u/19007038/13%20Inte...C%20The%20E.m4a
(I know it's an m4a extension, but the same issue happens on m4b's)

Thanks to valekhz or anyone else who can help with this!


--no-mp4v2 works for me
Go to the top of the page
+Quote Post
cynepnaxa
post Jul 17 2012, 01:08
Post #45





Group: Members
Posts: 2
Joined: 15-July 12
Member No.: 101434



QUOTE (cynepnaxa @ Jul 15 2012, 02:35) *
Valekhz's script is working fine.

And soon i found problems with unicode filenames on linux. I fix it, but then i found that it's looks like already fixed in Ramovsky's branch:
https://github.com/ramovsky/m4b-converter
Go to the top of the page
+Quote Post
vitos
post Aug 22 2012, 11:29
Post #46





Group: Members
Posts: 103
Joined: 7-February 05
From: Warsaw, Poland
Member No.: 19663



QUOTE (ertdredge @ Oct 16 2011, 04:57) *
As with everyone who's posted, major props to valekhz for building and maintaining this.

I got this working on Mac (Snow Leopard 10.6) with some fiddling:


Thank you!
(especially that you registered here just for sharing this useful extra information for OS X users)


--------------------
Not really a Signature.
Go to the top of the page
+Quote Post
theviki
post Aug 31 2012, 12:48
Post #47





Group: Members
Posts: 1
Joined: 31-August 12
Member No.: 102809



If this is still relevant, I found an easier way.
(The script works great though)
This is much more simpler.
1. Get bigsoftasses Audio Converter from here: http://www.bigsoftasses.com/audio-converter.html
Or the full version for free from here (Windows only): http://adf.ly/CQezy
* To install it, run 'Software' and follow the onscreen instructions.
Run the program.
Register with any name, and key from 'Serial.txt'.
2. Follow this article: http://www.bigsoftasses.com/articles/convert-m...-converter.html

I do not encourage piracy, and please support the developers by buying the product, like I have.
Please use it for testing purposes only, and uninstall it when you're done.
Go to the top of the page
+Quote Post
nmallears
post Jun 18 2013, 17:15
Post #48





Group: Members
Posts: 1
Joined: 18-June 13
Member No.: 108712



QUOTE (Jaantat @ Jun 16 2012, 07:30) *
I tried all different versions but still it makes just one mp3 file sad.gif
Can someone help me out?
i can see that it reads the chapter names but it wont make multiple files

CODE
C:\Python27>python m4b.py --debug game.m4b
INFO: m4bsplit started.
DEBUG: Options:
ffmpeg: ffmpeg
custom_name: %(title)s
skip_encoding: False
filename: ['game.m4b']
encoder: ffmpeg
ext: mp3
encode_opts: -y -i %(infile)s -acodec libmp3lame -ar %(sample_rate)d -ab %(b
it_rate)dk %(outfile)s
output_dir:
debug: True
pipe_wav: False
no_mp4v2: False
INFO: Initiating script for file 'game.m4b'.
INFO: Loading metadata using libmp4v2...
INFO:
Metadata:
Chapters: 135
Bit rate: 64 kbit/s
Sampling freq: 22050 Hz
DEBUG:
Chapter data:
<Chapter Title="00 - Prologue 1", Start=0:00:00, End=0:10:00, Dura
tion=0:10:00>
<Chapter Title="Part 1.1", Start=0:10:00, End=0:20:00, Duration=0:10:00>
<Chapter Title="Part 1.2", Start=0:20:00, End=0:24:33.005000, Duration=0:04:33.0
05000>
-----------------------
-----------------------
<Chapter Title="Part 38.3", Start=16:09:59.963000, End=16:17:54.605000, Duration
=0:07:54.642000>
INFO: Encoding audio...
DEBUG: Encoding with command: ffmpeg -y -i game.m4b -acodec libmp3lame -ar 22050
-ab 64k game\temp\game.mp3
ffmpeg version N-41416-g718607b Copyright © 2000-2012 the FFmpeg developers
built on Jun 8 2012 12:46:19 with gcc 4.6.3
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass
--enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable
-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libope
njpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libth
eora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-
libvorbis --enable-libvpx --ena libavutil 51. 56.100 / 51. 56.100
libavcodec 54. 25.100 / 54. 25.100
libavformat 54. 6.101 / 54. 6.101
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 78.101 / 2. 78.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'game.m4b':
Metadata:
major_brand : M4A
minor_version : 0
compatible_brands: 3gp5isom
creation_time : 2011-04-30 13:52:34
genre : Audiobook
media_type : 2
encoder : Chapter and Verse V 1.4
title : 01 - A Game of Thrones - Part 1
artist : George R.R. Martin
album : A Game of Thrones
composer : George R.R. Martin
track : 1/2
Duration: 16:17:54.64, start: 0.000000, bitrate: 60 kb/s
Chapter #0.0: start 0.000000, end 600.000000
Metadata:
title : 00 - Prologue 1
Chapter #0.1: start 600.000000, end 1200.000000
Metadata:
title : Part 1.1
-----------------------------
-------------------------------
Metadata:
title : Part 38.1
Chapter #0.133: start 57600.000000, end 58200.000000
Metadata:
title : Part 38.2
Chapter #0.134: start 58200.000000, end 58674.642721
Metadata:
title : Part 38.3
Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, stereo, s16, 59
kb/s
Metadata:
creation_time : 2011-04-30 13:52:34
Stream #0:1(und): Subtitle: mov_text (text / 0x74786574)
Metadata:
creation_time : 2011-04-30 13:54:41
Output #0, mp3, to 'game\temp\game.mp3':
Metadata:
major_brand : M4A
minor_version : 0
compatible_brands: 3gp5isom
TDEN : 2011-04-30 13:52:34
TCON : Audiobook
media_type : 2
TRCK : 1/2
TIT2 : 01 - A Game of Thrones - Part 1
TPE1 : George R.R. Martin
TALB : A Game of Thrones
TCOM : George R.R. Martin
TSSE : Lavf54.6.101
Chapter #0.0: start 0.000000, end 600.000000
Metadata:
title : 00 - Prologue 1
Chapter #0.1: start 600.000000, end 1200.000000
Metadata:
title : Part 1.1
Chapter #0.2: start 1200.000000, end 1473.005442
Metadata:
title : Part 1.2
Chapter #0.3: start 1473.005442, end 1800.000000
------------------
-------------------
Metadata:
title : Part 38.2
Chapter #0.134: start 58200.000000, end 58674.642721
Metadata:
title : Part 38.3
Stream #0:0(und): Audio: mp3, 22050 Hz, stereo, s16, 64 kb/s
Metadata:
creation_time : 2011-04-30 13:52:34
Stream mapping:
Stream #0:0 -> #0:0 (aac -> libmp3lame)
Press [q] to stop, [?] for help
size= 458397kB time=16:17:54.65 bitrate= 64.0kbits/s
video:0kB audio:458396kB global headers:0kB muxing overhead 0.000119%
INFO: Splitting chapter 1/135 '00 - Prologue 1'...
DEBUG: Splitting with command: ffmpeg -y -acodec copy -t 600.0 -ss 0.0 -i game\t
emp\game.mp3 game\_tmp_1.mp3
ERROR:
An error occurred while splitting audio file.
Command: ffmpeg -y -acodec copy -t 600.0 -ss 0.0 -i game\temp\game.mp3 game\_t
mp_1.mp3
Return code: 1
Output: ---->
ffmpeg version N-41416-g718607b Copyright © 2000-2012 the FFmpeg developers
built on Jun 8 2012 12:46:19 with gcc 4.6.3
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass
--enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable
-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libope
njpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libth
eora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-
libvorbis --enable-libvpx --ena libavutil 51. 56.100 / 51. 56.100
libavcodec 54. 25.100 / 54. 25.100
libavformat 54. 6.101 / 54. 6.101
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 78.101 / 2. 78.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Unknown decoder 'copy'



I know this was a year ago, but I had the same issue, and tracked down the cause, so to document it for anyone else who comes along later like me:

The problem is that the ffmpeg folks changed how they parse the command line somewhere around early November of 2011, so if your version of ffmpeg is too recent, it won't work with the ffmpeg commands generated by this script. See here: https://bugs.archlinux.org/task/27647 for more details.

So your options are to "downgrade" ffmpeg, or update the script to rearrange the ffmpeg commands.
Go to the top of the page
+Quote Post

2 Pages V  < 1 2
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 16th September 2014 - 09:14