Difference between revisions of "Audiobook"

From ArchWiki
Jump to: navigation, search
(Scenario 3: Make an m4b file from a single mp3 file)
(22 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{i18n|Audiobook}}
+
[[Category:Audio/Video]]
 
+
 
{{Article summary start}}
 
{{Article summary start}}
 
{{Article summary text|
 
{{Article summary text|
 
The purpose of this article is to detail a process to create an iPod friendly audiobook from digital media using Linux native tools.  It is arranged in goal-oriented scenarios.}}
 
The purpose of this article is to detail a process to create an iPod friendly audiobook from digital media using Linux native tools.  It is arranged in goal-oriented scenarios.}}
 
 
{{Article summary heading|Related}}
 
{{Article summary heading|Related}}
 
{{Article summary wiki|iPod}}
 
{{Article summary wiki|iPod}}
 
{{Article summary end}}
 
{{Article summary end}}
  
== Background and Tools==
+
An audiobook for iPods is nothing more than a discrete audio stream + metadata wrapped together in an m4b container.  The audio must be an aac encoded stream and the chapter-index metadata has its own Quicktime standard.  Multiple tools can be used to create these.
An audiobook for iPod or a "m4b" file, is nothing more than a chapter-index audio file (usually encoded to aac).  Multiple tools can be used to create these:
+
{{Wikipedia|.m4b}}
{{Wikipedia|.m4b}}  
+
  
*{{AUR|m4baker}} - Available from the [[AUR]], used to combine a group of already ripped audiofiles into a single m4b file with chapter marks.
+
== Tools ==
*{{Pkg|gpac}} - Available from [community], this collection of CLI tools are more flexible than m4baker and can be used to create chapter marks for existing m4b files that are without them.
+
=== GUI based tools===
*{{Pkg|mp3splt}} - Available from [extra], used to split a single, large mp3 file into smaller mp3 files.
+
*{{AUR|m4baker}} - Used to combine a group of already ripped audiofiles into a single m4b file with chapter marks.
*{{AUR|makechapterlist}} - Available from the [[AUR]], used to generate a chapters file for MP4Box (part of gpac).
+
  
== Scenario 1: Make an m4b file from individual mp3 files ==
+
=== CLI based tools ===
Overview:
+
*{{AUR|neroaacenc}} - Aac encoder.
# Use m4baker to combine many mp3 files into a single m4b file
+
*{{Pkg|lame}} - Mp3 encoder/decoder
 +
*{{Pkg|gpac}} - Needed for manipulating mp4 files.
 +
*{{Pkg|mediainfo}} - Displays many aspects of audio and video files.
 +
*{{AUR|makechapterlist}} - Makes a chapter list automatically.
  
Required software:
+
== Make an m4b file from multiple audio CDs ==
*{{AUR|m4baker}}
+
=== Extract audio from CDs and making multiple tracks, one per chapter ===
 +
Use one of the many fine CD rippers available to extract and encode the many CDs in a typical audiobook into aac encoded files.  (Out of scope for this tutorial).
 +
{{Note|File extensions need not be .aac but the audio stream DOES need to be in aac format.}}
  
Details:
+
=== Use m4baker to assemble the indiviual tracks into a single m4b file ===
 +
Usage of m4baker is very straightforward.  Detailed usage is explained on the [[http://code.google.com/p/m4baker/w/list project wiki]].  Be aware that the default qualitizer setting for faac is 100.  Some sources may require tweaking.  Faac takes values of 10 - 500 for the -q option.
  
== Scenario 2: Make an m4b file from individual mp4 files ==
+
== Make an m4b file from a single mp3 file or from multiple mp3 files ==
Overview:
+
=== Predominantly using m4baker ===
# Concatenate several mp4 files with MP4Box
+
{{Note|This guide assumes that the requisite mp3 file(s) do not correspond to the natural chapter breaks of the narrative. }}
  
Required software:  
+
Users have several options to define chapter marks.  One is to define arbitrary "chapter markers" using a set time interval (i.e. 10 min) to define the chapter breaks.  Another method can make use of silence detection to automatically break up chapter points.  In either case, a single file is required.
*{{AUR|gpac}}
+
==== Make a single mp3 file  ====
 +
If not already starting from one, simply concatenate them into a single file:
 +
$ MP4Box -cat 1.mp3 -cat 2.mp3 final.mp3
  
Details:
+
==== Split the file into chapters ====
Individual mp4 files are easily cat'ed together using MP4Box's cat mode:
+
Split the single file into chapters.  In this example, a contains time of 10 min is used:
  $ MP4Box -cat file1.mp4 -cat file2.mp4 output.mp4
+
  $ mp3splt -f -t 10.0 final.mp3 -o @n
  
The cat switch works with all streams supported in MP4Box, like ASP, AVC, AAC, MPEG-1/2 Audio and Video (eg MP3), TTXT and even on Vobsubs and ALAC.
+
See the mp3splt manpage for additional options and for an explanation of the options used above.
== Scenario 3: Make an m4b file from a single mp3 file ==
+
Overview:
+
# Decode the single mp3 file to wav and re-encocde it to aac
+
# Split the single mp3 file into even breaks constituting chapters
+
# Use m4baker to combine into a single m4b file
+
  
Required software:
+
This example uses the auto silence mode wherein the file is scanned for periods of silence and split points generated from them. 
*{{AUR|neroaacenc}}
+
*{{Pkg|lame}}
+
  
Details:
+
$ mp3splt -f -s -p -min=3 final.mp3
Decode the mp3 file to wav then re-encode it to aac:
+
  
$ lame --decode target.mp3
+
{{Note|This mode is NOT general and requires considerable tweaking to workSee the man page for more options.}}
  $ neroAacEnc -q 0.6 -if target.wav -of target.aac
+
  
== Scenario 4: Add chapter marks to an existing m4b file without them ==
+
==== Use m4baker to assemble the indiviual tracks into a single m4b file ====
Overview:
+
Usage of m4baker is very straightforward.  Detailed usage is explained on the [[http://code.google.com/p/m4baker/w/list project wiki]].  Be aware that the default qualitizer setting for faac is 100.  Some sources may require tweaking.  Faac takes values of 10 - 500 for the -q option.
# Generate a chapter list which defines the chapter marks
+
# Merge the chapter list with the audio data
+
# Convert the file to qt format
+
# Rename the file to the finalized m4b
+
  
Required software:
+
=== Using only CLI tools ===
*{{Pkg|gpac}}
+
==== Decode and make aac formatted file(s) ====
*{{Pkg|mediainfo}}
+
Since iPods require aac formatted audio, mp3 files need to be transcoded into aac.  First, decode the source mp3 file to wav.  Repeat if multiple mp3 files constitute an entire book:
*{{AUR|makechapterlist}}
+
$ lame --decode book.mp3
  
Details:
+
Encode the wav file(s) to aac:
First, determine how long the mp4 file is using mediainfo:
+
$ neroAacEnc -q 0.7 -if book.wav -of book.aac
  
  $ mediainfo --inform="Audio;%Duration/String3%" book.mp4
+
{{Tip|If multiple files are used, make use of a for loop to process them in one line.}}
 +
$ for i in *.mp3; do lame --decode "$i"; done
 +
$ for i in *.wav; do neroAacEnc -q 0.7 -if "$i" -of "${i%.*}".aac; done
 +
 
 +
==== Optionally combine multiple aac files into a single file ====
 +
Multiple aac files need to be concatenated into a single file:
 +
$ MP4Box -cat 1.aac -cat 2.aac book.aac
 +
 
 +
==== Create metadata for chapter marks ====
 +
Determine the overall length of the aac:
 +
  $ mediainfo --inform="Audio;%Duration/String3%" book.aac
 
  19:04:53.874
 
  19:04:53.874
  
In this example, the mp4 file is 19h 4m and 54 s.
+
In this example, the file is 19h 4m and 54 s long.  
  
Next, create a chapter list to break up the file into "chapters" or more digestible parts.  The list itself is nothing more than a text file in a specific format (Nero chapter format to be precise).  Use {{ic|makechapterlist}} to make this automatically.
+
Create a chapter list to break up the file into "chapters" or more digestible parts.  The list itself is nothing more than a text file in a specific format (Nero chapter format to be precise).  Use {{ic|makechapterlist}} to make this automatically.
  
 
{{Note|The current version of makechapterlist simply makes chapter marks at 10 minute intervals.  To have the chapter marks coincide with the actual chapter breaks in the audio file, knowledge about when a chapter begins/ends is needed.}}
 
{{Note|The current version of makechapterlist simply makes chapter marks at 10 minute intervals.  To have the chapter marks coincide with the actual chapter breaks in the audio file, knowledge about when a chapter begins/ends is needed.}}
Line 86: Line 87:
 
  Done!  /home/facade/chapter.list written.
 
  Done!  /home/facade/chapter.list written.
  
The next step is to make the metadata in {{ic|chapter.list}} with the audio mp4 file.  This is accomplished using {{ic|MP4Box}}:
+
==== Hardcode the metadata into the audio file ====
  $ MP4Box -add book.mp4 -chap chapters.list book1.mp4
+
The next step is to merge the metadata in {{ic|chapter.list}} with the audio file.  This is accomplished using {{ic|MP4Box}}:
 +
  $ MP4Box -add book.aac -chap chapters.list book.mp4
  
 
The resulting file now needs to be converted to Quicktime chapter markers using {{ic|mp4chaps}}:
 
The resulting file now needs to be converted to Quicktime chapter markers using {{ic|mp4chaps}}:
  $ mp4chaps –convert –chapter-qt book1.mp4
+
  $ mp4chaps –convert –chapter-qt book.mp4
 +
 
 +
==== Rename the merged file ====
  
 
The final step is to simply rename the mp4 file to the m4b extension:
 
The final step is to simply rename the mp4 file to the m4b extension:
  $ mv book1.mp4 book1.m4b
+
  $ mv book.mp4 book.m4b
 +
 
 +
Users can now optionally edit the tags in the file with any number of tools.  Using {{Pkg|vlc}} is easy.  Simply load the file and hit {{ic|Ctrl}} + {{ic|i}} to bring up a tag window.  Save the metadata before exiting.
 +
 
 +
== Add chapter marks to an existing m4b file without them ==
 +
 
 +
This process is identical to [[Audiobook#3._Create_metadata_for_chapter_marks|steps 3-5]] detailed in Scenario 2.
 +
 
 +
== Break up an m4b file into individual files ==
 +
Some stereo systems in cars are not capable of using the metadata (chapter marks) within an m4b file.  It is therefore necessary to break up the m4b file into individual "chapter" files.
 +
 
 +
=== Into equal chunks ===
 +
# Rename the m4b file to mp4
 +
# Invoke the -split ''sec'' option of MP4Box:
 +
 
 +
$ mv target.m4b target.mp4
 +
$ MP4Box -split 600 target.mp4
  
Users can now optionally edit the tags in the file with any number of tools.  Using {{Pkg|vlc}} is easy.  Simply load the file and hit {{Keypress|Ctrl}} + {{Keypress|i}} to bring up a tag window.  Save the metadata before exiting.
+
=== Based on metadata in original m4b file ===

Revision as of 11:09, 1 September 2013

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary end

An audiobook for iPods is nothing more than a discrete audio stream + metadata wrapped together in an m4b container. The audio must be an aac encoded stream and the chapter-index metadata has its own Quicktime standard. Multiple tools can be used to create these. Template:Wikipedia

Tools

GUI based tools

  • m4bakerAUR - Used to combine a group of already ripped audiofiles into a single m4b file with chapter marks.

CLI based tools

  • neroaacencAUR - Aac encoder.
  • lame - Mp3 encoder/decoder
  • gpac - Needed for manipulating mp4 files.
  • mediainfo - Displays many aspects of audio and video files.
  • makechapterlistAUR - Makes a chapter list automatically.

Make an m4b file from multiple audio CDs

Extract audio from CDs and making multiple tracks, one per chapter

Use one of the many fine CD rippers available to extract and encode the many CDs in a typical audiobook into aac encoded files. (Out of scope for this tutorial).

Note: File extensions need not be .aac but the audio stream DOES need to be in aac format.

Use m4baker to assemble the indiviual tracks into a single m4b file

Usage of m4baker is very straightforward. Detailed usage is explained on the [project wiki]. Be aware that the default qualitizer setting for faac is 100. Some sources may require tweaking. Faac takes values of 10 - 500 for the -q option.

Make an m4b file from a single mp3 file or from multiple mp3 files

Predominantly using m4baker

Note: This guide assumes that the requisite mp3 file(s) do not correspond to the natural chapter breaks of the narrative.

Users have several options to define chapter marks. One is to define arbitrary "chapter markers" using a set time interval (i.e. 10 min) to define the chapter breaks. Another method can make use of silence detection to automatically break up chapter points. In either case, a single file is required.

Make a single mp3 file

If not already starting from one, simply concatenate them into a single file:

$ MP4Box -cat 1.mp3 -cat 2.mp3 final.mp3

Split the file into chapters

Split the single file into chapters. In this example, a contains time of 10 min is used:

$ mp3splt -f -t 10.0 final.mp3 -o @n

See the mp3splt manpage for additional options and for an explanation of the options used above.

This example uses the auto silence mode wherein the file is scanned for periods of silence and split points generated from them.

$ mp3splt -f -s -p -min=3 final.mp3
Note: This mode is NOT general and requires considerable tweaking to work. See the man page for more options.

Use m4baker to assemble the indiviual tracks into a single m4b file

Usage of m4baker is very straightforward. Detailed usage is explained on the [project wiki]. Be aware that the default qualitizer setting for faac is 100. Some sources may require tweaking. Faac takes values of 10 - 500 for the -q option.

Using only CLI tools

Decode and make aac formatted file(s)

Since iPods require aac formatted audio, mp3 files need to be transcoded into aac. First, decode the source mp3 file to wav. Repeat if multiple mp3 files constitute an entire book:

$ lame --decode book.mp3

Encode the wav file(s) to aac:

$ neroAacEnc -q 0.7 -if book.wav -of book.aac
Tip: If multiple files are used, make use of a for loop to process them in one line.
$ for i in *.mp3; do lame --decode "$i"; done
$ for i in *.wav; do neroAacEnc -q 0.7 -if "$i" -of "${i%.*}".aac; done

Optionally combine multiple aac files into a single file

Multiple aac files need to be concatenated into a single file:

$ MP4Box -cat 1.aac -cat 2.aac book.aac

Create metadata for chapter marks

Determine the overall length of the aac:

$ mediainfo --inform="Audio;%Duration/String3%" book.aac
19:04:53.874

In this example, the file is 19h 4m and 54 s long.

Create a chapter list to break up the file into "chapters" or more digestible parts. The list itself is nothing more than a text file in a specific format (Nero chapter format to be precise). Use makechapterlist to make this automatically.

Note: The current version of makechapterlist simply makes chapter marks at 10 minute intervals. To have the chapter marks coincide with the actual chapter breaks in the audio file, knowledge about when a chapter begins/ends is needed.

The example file calls for roughly 19h 5m of content, but the script uses 10 m intervals so a sane value is simply 19x6=114 chapters.

$ makechapterlist
Writes chapter files using a 10 min interval for each chapter
How many chapters are needed: 114
Done!  /home/facade/chapter.list written.

Hardcode the metadata into the audio file

The next step is to merge the metadata in chapter.list with the audio file. This is accomplished using MP4Box:

$ MP4Box -add book.aac -chap chapters.list book.mp4

The resulting file now needs to be converted to Quicktime chapter markers using mp4chaps:

$ mp4chaps –convert –chapter-qt book.mp4

Rename the merged file

The final step is to simply rename the mp4 file to the m4b extension:

$ mv book.mp4 book.m4b

Users can now optionally edit the tags in the file with any number of tools. Using vlc is easy. Simply load the file and hit Ctrl + i to bring up a tag window. Save the metadata before exiting.

Add chapter marks to an existing m4b file without them

This process is identical to steps 3-5 detailed in Scenario 2.

Break up an m4b file into individual files

Some stereo systems in cars are not capable of using the metadata (chapter marks) within an m4b file. It is therefore necessary to break up the m4b file into individual "chapter" files.

Into equal chunks

  1. Rename the m4b file to mp4
  2. Invoke the -split sec option of MP4Box:
$ mv target.m4b target.mp4
$ MP4Box -split 600 target.mp4

Based on metadata in original m4b file