VideoHelp Forum

+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. I have single large M4B container with audio book split into multiple chapters.

    Is there quick way to extract chapters as separate files that will not require re-encoding to another format?
    Quote Quote  
  2. Not sure if it works (never seen a M4B container, guess it's standard AAC audio with some kind of dedicated metadata), but I would try to import it in MKVToolNix, then in the "Output" tab, select "Split mode: Before chapters". If MKVToolNix does recognize the format, should produce one MKV (or MKA) file for each chapter. If not, you'd have to re-create a chapter template.
    Quote Quote  
  3. m4b is a mp4 audio container, it should be possible to extract the chapters to .m4a / .aac files without reencoding.
    Quote Quote  
  4. m4b is a mp4 audio container, it should be possible to extract the chapters to .m4a / .aac files without reencoding.
    Alright. How ?
    Quote Quote  
  5. split audio into 20 min equal time interval segments split00.mp3, split01.mp3, split02.mp3, split03.mp3

    ffmpeg -i input.m4b -c copy -f segment -segment_time 20:00 -reset_timestamps 1 split%02d.mp3

    -reset_timestamps 1 is critical as for each segment it recalculates the time
    %02d outputs 00, 01, 02, 03, etc. change to %03d for 000, 001, 002, 003, etc.

    split an m4b audiobook into multiple mka or mkv audio files for each chapter (if it already has chapters) with MKVToolnix. Drag m4b file into MKVToolnix into Multiplexer then choose Output
    Image
    [Attachment 60825 - Click to enlarge]


    Note: same can be done with Freac by importing m4b and outputting an mp3 for each chapter

    also probably best just done with m4b-tool

    m4b-tool split --audio-format mp3 --audio-bitrate 96k --audio-channels 1 --audio-samplerate 22050 "data/my-audio-book.m4b"
    Quote Quote  
  6. m4b seems to be m4a + chapters. If this holds the following is possible via script:
    - extract a section losslessly with ffmpeg using timestamps
    - or extract chapters to mka with mkvtoolnix/mkvmerge then remux to .aac/m4a losslessly with ffmpeg.

    note:
    - audiobooks don't typically have same length chapters.
    - any conversion to mp3 implies recompression.
    Quote Quote  
  7. Originally Posted by butterw View Post
    m4b seems to be m4a + chapters. If this holds the following is possible via script:
    - extract a section losslessly with ffmpeg using timestamps
    - or extract chapters to mka with mkvtoolnix/mkvmerge then remux to .aac/m4a losslessly with ffmpeg.

    note:
    - audiobooks don't typically have same length chapters.
    - any conversion to mp3 implies recompression.
    I was also looking for a way to do this and came across this thread. butterw alluded to how to do it and with a little of my own research came up with the following solution.

    It turns out you can easily do this from the command line using MKVToolNix (specifically mkvmerge) and FFMPEG. This is in Windows; other OSes would just need to change the syntax of the "for" loop accordingly.

    This first step will split the m4b file into individual mka (Matroska audio) files at each chapter marker in the m4b. This is lossless as you are only changing from an MP4 container to a Mastroska container; the actual audio stream is not transcoded.
    Code:
    C:\> C:\path\to\mkvmerge -o output.mka --split chapters:all input.m4b
    Once you have individual mka files, you can use FFMPEG to put the audio streams back into MP4 containers, again without transcoding.
    Code:
    C:\> for %f in (*.mka) do C:\path\to\ffmpeg -i "%f" -c:a copy -vn -f mp4 "%~nf.m4b"
    This will loop through all the mka files you created and put each audio stream into an mp4 container with an m4b extension. (For those interested, "-c:a copy" copies the audio stream without transcoding, "-vn" tells FFMPEG that there will be no video stream in the output and "-f mp4" specifies an MP4 format container.)

    I know it's not sexy, but it's got teeth.

    Last I checked, MP4Box of the GPAC Framework will split at specific times and not chapter metadata just like FFMPEG. But this feature has been requested to be added to MP4Box, so maybe it will appear some time soon.
    Quote Quote