Merge branch 'master' of github.com:KrumpetPirate/AAXtoMP3 into audible-cli-integration

This commit is contained in:
fabh2o 2021-02-05 15:38:35 +01:00
commit 1f0b44d455
2 changed files with 46 additions and 2 deletions

View File

@ -5,9 +5,10 @@
# Command Line Options # Command Line Options
# Usage Synopsis. # Usage Synopsis.
usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--chaptered]\n[-e:mp3] [-e:m4a] [-e:m4b] [--authcode <AUTHCODE>] [--no-clobber]\n[--target_dir <PATH>] [--complete_dir <PATH>] [--validate]\n[--continue <CHAPTERNUMBER>]{FILES}\n' usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--level <COMPRESSIONLEVEL>]\n[--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [--authcode <AUTHCODE>] [--no-clobber]\n[--target_dir <PATH>] [--complete_dir <PATH>] [--validate]\n[--continue <CHAPTERNUMBER>]{FILES}\n'
codec=libmp3lame # Default encoder. codec=libmp3lame # Default encoder.
extension=mp3 # Default encoder extension. extension=mp3 # Default encoder extension.
level=-1 # Compression level. Can be given for mp3, flac and opus. -1 = default/not specified.
mode=chaptered # Multi file output mode=chaptered # Multi file output
auth_code= # Required to be set via file or option. auth_code= # Required to be set via file or option.
targetdir= # Optional output location. Note default is basedir of AAX file. targetdir= # Optional output location. Note default is basedir of AAX file.
@ -59,6 +60,8 @@ while true; do
--continue ) continueAt="$2"; continue=1; shift 2 ;; --continue ) continueAt="$2"; continue=1; shift 2 ;;
# Use additional data got with mkb79/audible-cli # Use additional data got with mkb79/audible-cli
--use-audible-cli-data ) audibleCli=1; shift ;; --use-audible-cli-data ) audibleCli=1; shift ;;
# Compression level
--level ) level="$2"; shift 2 ;;
# Command synopsis. # Command synopsis.
-h | --help ) printf "$usage" $0 ; exit ;; -h | --help ) printf "$usage" $0 ; exit ;;
# Standard flag signifying the end of command line processing. # Standard flag signifying the end of command line processing.
@ -266,6 +269,34 @@ if [[ "x${completedir}" != "x" ]]; then
fi fi
fi fi
# -----
# If a compression level is given, check whether the given codec supports compression level specifiers and whether the level is valid.
if [ "${level}" != "-1" ]; then
if [ "${codec}" == "flac" ]; then
if [ "$((${level} < 0 || ${level} > 12 ))" = "1" ]; then
echo "ERROR Flac compression level has to be in the range from 0 to 12!"
echo "$usage"
exit 1
fi
elif [ "${codec}" == "libopus" ]; then
if [ "$((${level} < 0 || ${level} > 10 ))" = "1" ]; then
echo "ERROR Opus compression level has to be in the range from 0 to 10!"
echo "$usage"
exit 1
fi
elif [ "${codec}" == "libmp3lame" ]; then
if [ "$((${level} < 0 || ${level} > 9 ))" = "1" ]; then
echo "ERROR MP3 compression level has to be in the range from 0 to 9!"
echo "$usage"
exit 1
fi
else
echo "ERROR This codec doesnt support compression levels!"
echo "$usage"
exit 1
fi
fi
# ----- # -----
# Clean up if someone hits ^c or the script exits for any reason. # Clean up if someone hits ^c or the script exits for any reason.
trap 'rm -r -f "${working_directory}"' EXIT trap 'rm -r -f "${working_directory}"' EXIT
@ -479,6 +510,12 @@ do
# and coders wanting to extend the script. # and coders wanting to extend the script.
debug_vars "Book and Variable values" title auth_code mode aax_file container codec bitrate artist album_artist album album_date genre copyright narrator description publisher output_file metadata_file working_directory debug_vars "Book and Variable values" title auth_code mode aax_file container codec bitrate artist album_artist album album_date genre copyright narrator description publisher output_file metadata_file working_directory
# If level != -1 specify a compression level in ffmpeg.
compression_level_param=""
if [ "${level}" != "-1" ]; then
compression_level_param="-compression_level ${level}"
fi
# ----- # -----
if [ "${continue}" == "0" ]; then if [ "${continue}" == "0" ]; then
# This is the main work horse command. This is the primary transcoder. # This is the main work horse command. This is the primary transcoder.
@ -490,6 +527,7 @@ do
-i "${aax_file}" \ -i "${aax_file}" \
-vn \ -vn \
-codec:a "${codec}" \ -codec:a "${codec}" \
${compression_level_param} \
-ab ${bitrate} \ -ab ${bitrate} \
-map_metadata -1 \ -map_metadata -1 \
-metadata title="${title}" \ -metadata title="${title}" \
@ -601,6 +639,7 @@ do
-map 1:0 \ -map 1:0 \
-acodec "${codec}" \ -acodec "${codec}" \
${id3_version_param} \ ${id3_version_param} \
${compression_level_param} \
-metadata:s:v title="Album cover" \ -metadata:s:v title="Album cover" \
-metadata:s:v comment="Cover (Front)" \ -metadata:s:v comment="Cover (Front)" \
-metadata track="${chapternum}" \ -metadata track="${chapternum}" \

View File

@ -30,7 +30,7 @@ Thanks to kbabioch, this script has also been packaged in the [AUR](https://aur.
## Usage(s) ## Usage(s)
``` ```
bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [-c|--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [-A|--authcode <AUTHCODE>] [-n|--no-clobber] [-t|--target_dir <PATH>] [-C|--complete_dir <PATH>] [-V|--validate] [-d|--debug] [-h|--help] [--continue <CHAPTERNUMBER>] <AAX INPUT_FILES>... bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level <COMPRESSIONLEVEL>] [-c|--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [-A|--authcode <AUTHCODE>] [-n|--no-clobber] [-t|--target_dir <PATH>] [-C|--complete_dir <PATH>] [-V|--validate] [-d|--debug] [-h|--help] [--continue <CHAPTERNUMBER>] <AAX INPUT_FILES>...
``` ```
* **&lt;AAX INPUT_FILES&gt;**... are considered input file(s), useful for batching! * **&lt;AAX INPUT_FILES&gt;**... are considered input file(s), useful for batching!
@ -50,8 +50,10 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [-c|--chaptered] [
* **-s** or **--single** Output a single file for the entire book. If you only want a single ogg file for instance. * **-s** or **--single** Output a single file for the entire book. If you only want a single ogg file for instance.
* **-c** or **--chaptered** Output a single file per chapter. The `--chaptered` will only work if it follows the `--aac -e:m4a -e:m4b --flac` options. * **-c** or **--chaptered** Output a single file per chapter. The `--chaptered` will only work if it follows the `--aac -e:m4a -e:m4b --flac` options.
* **--continue &lt;CHAPTERNUMBER&gt;** If the splitting into chapters gets interrupted (e.g. by a weak battery on your laptop) you can go on where the process got interrupted. Just delete the last chapter (which was incompletely generated) and redo the task with "--continue &lt;CHAPTERNUMBER&gt;" where CHAPTERNUMBER is the chapter that got interrupted. * **--continue &lt;CHAPTERNUMBER&gt;** If the splitting into chapters gets interrupted (e.g. by a weak battery on your laptop) you can go on where the process got interrupted. Just delete the last chapter (which was incompletely generated) and redo the task with "--continue &lt;CHAPTERNUMBER&gt;" where CHAPTERNUMBER is the chapter that got interrupted.
* **--level &lt;COMPRESSIONLEVEL&gt;** Set compression level. May be given for mp3, flac and opus.
* **--use-audible-cli-data** Use additional data got with mkb79/audible-cli. See [below](#audible-cli-integration) for more infos. * **--use-audible-cli-data** Use additional data got with mkb79/audible-cli. See [below](#audible-cli-integration) for more infos.
### [AUTHCODE] ### [AUTHCODE]
**Your** Audible auth code (it won't correctly decode otherwise) (required). **Your** Audible auth code (it won't correctly decode otherwise) (required).
@ -74,11 +76,13 @@ __Note:__ At least one of the above must be exist. The code must also match the
* The default mode is **chaptered** * The default mode is **chaptered**
* If you want a mp3 file per chapter do not use the **--single** option. * If you want a mp3 file per chapter do not use the **--single** option.
* A m3u playlist file will also be created in this instance in the case of **default** chaptered output. * A m3u playlist file will also be created in this instance in the case of **default** chaptered output.
* **--level** has to be in range 0-9, where 9 is fastest and 0 is highest quality. Please note: The quality can **never** become higher than the qualitiy of the original aax file!
### Ogg/Opus Encoding ### Ogg/Opus Encoding
* Can be done by using the **-o** or **--opus** command line switches * Can be done by using the **-o** or **--opus** command line switches
* The default mode is **chaptered** * The default mode is **chaptered**
* Opus coded files are stored in the ogg container format for better compatibility. * Opus coded files are stored in the ogg container format for better compatibility.
* **--level** has to be in range 0-10, where 0 is fastest and 10 is highest quality. Please note: The quality can **never** become higher than the qualitiy of the original aax file!
### AAC Encoding ### AAC Encoding
* Can be done by using the **-a** or **--aac** command line switches * Can be done by using the **-a** or **--aac** command line switches
@ -92,6 +96,7 @@ __Note:__ At least one of the above must be exist. The code must also match the
* The default mode is **single** * The default mode is **single**
* FLAC is an open format with royalty-free licensing * FLAC is an open format with royalty-free licensing
* This will only produce 1 audio file as output. If you want a flac file per chapter do use **-c** or **--chaptered**. * This will only produce 1 audio file as output. If you want a flac file per chapter do use **-c** or **--chaptered**.
* **--level** has to be in range 0-12, where 0 is fastest and 12 is highest compression. Since flac is lossless, the quality always remains the same.
### M4A and M4B Containers ### M4A and M4B Containers
* These containers were created by Apple Inc. They were meant to be the successor to mp3. * These containers were created by Apple Inc. They were meant to be the successor to mp3.