krumpetpirate / aaxtomp3 Goto Github PK
View Code? Open in Web Editor NEWConvert Audible's .aax filetype to MP3, FLAC, M4A, or OPUS
Home Page: https://krumpetpirate.github.io/AAXtoMP3/
License: Do What The F*ck You Want To Public License
Convert Audible's .aax filetype to MP3, FLAC, M4A, or OPUS
Home Page: https://krumpetpirate.github.io/AAXtoMP3/
License: Do What The F*ck You Want To Public License
A few notes from my point of view (as a packager), since you flagged the package out of date and I can't find your personal email-address:
I've created a new package (aaxtomp) for stable
releases. Maybe you can add it to your README.md, or so?
The aaxtomp-git won't be bumped each time there is a commit in this repository. You have to build it for yourself, if you want a more recent version. I will only update it, in case the build process breaks, e.g. when you rename the script, etc. ;).
I'm using the most recent tag (git describe) for the versioning (pkgver). This is definitely an improvement, so thank you very much :-). Maybe you want to use annotated tags, though, so you may want to have a look at it. git describe by default does not work with unannotated tags.
This is totally personal preferences, but I will mention it anyway: I think an integer versioning scheme makes more sense in cases like this (e.g. scripts). Not sure if a MAJOR.MINOR (e.g. 1.0) versioning scheme makes sense here, but this is up to you. In recent years there are a whole lot of "big" projects that just increase an integer (e.g. systemd, etc.), so you should consider this, too. Otherwise you get a headache when deciding whether to bump MAJOR or MINOR :-).
Hello, I'm out of my league trying to follow these instructions, but I believe I'm about 90% of the way there and I just need a little direction.
To set the table, my goal is to obtain my Audible Activation Bytes so that I can convert my .aax audio book files to .m4b while retaining the chapter info.
I installed Brew, FFMPEG, and Bash 4.4.23 enroute to attempting to follow instructions.
In an attempt to get my Audible Activation Bytes I ran the following lines in my macOS 10.13.5 Terminal
brew install chromedriver ffmpeg
sudo easy_install pip
pip install selenium requests
git clone https://github.com/inAudible-NG/audible-activator
cd audible-activator
sed -i '' 's,chromedriver_path = "./chromedriver",chromedriver_path = "/usr/local/bin/chromedriver",' audible-activator.py
./audible-activator.py
Everything seems to go fine until I get to the last command (./audible-activator.py) ...when I run that I get the response: env: python2: No such file or directory
So I'm not sure what to do, but if someone could help I would greatly appreciate it. Please let me know if there are any other details I can provide. Thanks! - Ben
On some audiobooks I get the following error when trying to extract chapter files when using --flac
Running bash AAXtoMP3 --flac *.aax
...
2018-06-18 11:31:24+0200 Extracting 18 chapter files from ./FILENAME.flac...
...
Stream mapping:
Stream #0:0 -> #0:0 (flac (native) -> flac (native))
Stream #1:0 -> #0:1 (mjpeg (native) -> ? (?))
...
Automatic encoder selection failed for output stream #0:1. Default encoder for format flac (codec none) is probably disabled. Please choose an encoder manually.
Error selecting an encoder for stream 0:1
Running bash AAXtoMP3 --flac FILENAME.aax
...
2018-06-18 11:31:24+0200 Extracting 18 chapter files from ./FILENAME.flac...
...
Stream mapping:
Stream #0:0 -> #0:0 (flac (native) -> flac (native))
Stream #1:0 -> #0:1 (mjpeg (native) -> ? (?))
...
Encoder (codec none) not found for output stream #0:1
Created a pull request with fix, see #72
Thank you for this great script. I've packaged it for Arch Linux within the AUR, so maybe you could mention it somewhere in the README :-).
I think this might have to do with the title extracted from the tags, happens to a couple of my books.
Input/Output:
jhbatley@jhbatley-Inspiron-24-3459:~/AAXtoMP3$ bash AAXtoMP3 0825db04 FinallyFree.aax
2018-06-12 20:01:46-0500 Decoding FinallyFree.aax with auth code 0825db04...
Unknown encoder 'libmp3lame0'
Using Ubuntu 18.04
Updated version of libmp3lame0
Updated version of ffmpeg
Thanks!
Thanks for the excellent package, it works like a charm. I tweaked it a little bit to serve my goals (Audible --> Google Play to be able to stream to Sonos) better. After the extracted mp3 is created, I changed the code to first create the cover art. Next, in the creation of the per-chapter files, I have added the chapter number to the title, fixed the chapter metadata, and added the cover art:
debug "Created ${full_file_path}."
cover_path="${output_directory}/cover.jpg"
debug "Extracting cover into ${cover_path}..."
</dev/null ffmpeg -loglevel error -activation_bytes "${auth_code}" -i "${path}" -an -codec:v copy "${cover_path}"
if [ "${mode}" == "chaptered" ]; then
debug "Extracting chapter files from ${full_file_path}..."
while read -r -u9 first _ _ start _ end
do
if [[ "${first}" = "Chapter" ]]
then
read -r -u9 _
read -r -u9 _ _ chapter
chapterarray=($chapter)
echo "${chapter} :: ${chapterarray[0]} :: ${chapterarray[1]}"
chapter_padding
chapter_file="${output_directory}/${title} - ${chapter}.${extension}"
chapter_file_with_cover="${output_directory}/${title} - ${chapter} - cover.${extension}"
</dev/null ffmpeg -loglevel error -stats -i "${full_file_path}" -ss "${start%?}" -to "${end}" -codec:a copy -metadata track="${chapterarray[1]}" -metadata title="${title} - ${chapter}" "${chapter_file}"
</dev/null ffmpeg -loglevel error -nostats -i "${chapter_file}" -i "${cover_path}" -c copy -map 0:0 -map 1:0 -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" "${chapter_file_with_cover}"
fi
done 9< "$metadata_file"
rm "${full_file_path}"
debug "Done creating chapters. Chaptered files contained in ${output_directory}."
fi
debug "Done."
Let me know if you want me to push this to github. Maybe the 'include cover' should be a command-line option.
Sometimes Amazon uses other chapter title strings than "Chapter <n>". For example "Kapitel <n>" in some german audiobooks. The chapter_padding() routine does only apply zero padding for the "Chapter.." string for the moment.
We could fix that by simply replacing any number with an insufficient digit count, no matter how the string begins.
A better solution would be building a substring like this:
"<padded chaptercount> <original chapter title>"
Example: "07 Chapter 7"
This way we would gain sortability while keeping the chapter title untouched.
Any comments on this?
I have tried on both Linux and MacOs and I am getting the same result for my book, I want to put on MP3 player:
2017-08-28 16:48:41-0700 Decoding TheArtofLiving.aax with auth code [code scrapped]...
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8489810600] [aax] mismatch in checksums!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8489810600] error reading header
TheArtofLiving.aax: Invalid data found when processing input
I have both lame and ffmpeg in place. Anything else I can help with?
Hello!
I saw in your code there was a commented-out section for just decryption of the stream, allowing 'lossless' decryption, speeding up the process immensely.
However, the used extension 'm4b' isn't recognized by ffmpeg, because it's an unofficial one, used by Apple to distinguish between regular audio and books, even though the files are technically the same.
Changing the extension from 'm4b' to 'm4a' for the format 'aac' allows your script to just decrypt the aax files, which is what I really wanted.
Thanks for this script!
Change
#if [[ "$1" == '--aac' ]]
#then
# codec=copy
# extension=m4b
# shift
#fi
to
if [[ "$1" == '--aac' ]]
then
codec=copy
extension=m4a
shift
fi
Hey there,
if there wouldn't be a hardcoded tmp.txt but an instance specific tmp-file it would be possible to run multiple instances (in the same directory).
BTW, thanks for your work, very helpful.
Hi,
Great Script file. Thank you.
Under OSX El Capitan with upgraded Bash 4.3, it was failing in chapter_padding because
grep option -P is not supported with the pre-installed FreeBSD grep.
Fix:
Additionally installing GNU Grep as ggrep v3.1 via homebrew and amending the script to ggrep -Pc instead did the job.
Additionally I have added double-quotes around
"$metadata_file"
chaptercount=$(ggrep -Pc "title\s+:\sChapter\s\d+" "$metadata_file")
HTH
If no chapter name is assigned in the ffprobe output, the script will attempt to assign BOOK - .mp3. This occurs in Ready Player One
You could replace the reference to the "audible-activator" (https://github.com/inAudible-NG/audible-activator) repository with the "tables" repository (https://github.com/inAudible-NG/tables) by the same author.
It's easier to use, offline and he recommends it himself.
See pull request #73
There doesn't appear to be a way to select a bit rate. The default quality is a little low. Could you include an option please?
This isn't really a code related issue but I figured the people who read this might know about it:
Does Audible instert hidden customer identifying watermarks in their audiobooks? And do they survive the conversion to MP3?
Thanks!
id3v2 from community repo on Arch should do the trick...
See below
I had opened a pull request for multithreading. This request was understandably denied because of merge-conflicts and changes. I could change the existing code in a way that would not interfere or change the existing AAXtoMP3-file whatsoever.
The multithreaded version would be a seperate file, with its own arguments (like jobnumber, etc). This file would not be affected by changes made in the main file.
I would change the code if it is wanted, but instead of doing it first i wanted an opinion here ;)
hi,
when invoked with the "--flac" option, the flac file is created as one large file. however, the script fails to cut the flac file into chapter segments. i get the following error message.
flac version: flac 1.3.1
[flac @ 0x25e6c20] only one stream is supported
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
an workable solution would be highly appreciated.
thanks
Titles with commas :
in the name get cutoff.
Star Wars: The Old Republic: Revan
-> Star Wars
This isn't a true problem until you are downloading a series of books like Title: Book Two
and so on and the files try to overwrite each other.
Let's convert them to hyphens -
.
PS - EXCELLENT project!
Everything worked fine with new instructions.
At the end I get the following message:
reinerb@UX305FA:~/aax2mp3tools/AAXtoMP3-master$ ./AAXtoMP3 ~/Dropbox/Audiolivres/DerWunschpunsch_Format Audible.aax
2018-02-16 23:29:38-0500 Decoding /home/reinerb/Dropbox/Audiolivres/DerWunschpunsch_Format with auth code ..
However no mp3 file is created.
Do ou have an idea?
I would like to submit a patch to output the m4b in lossless form, where the following fails
ffmpeg -activation_bytes "deadfeef" -i input.aax -codec:a copy -codec:v copy output.m4b
and this
ffmpeg -activation_bytes "deadfeef" -i input.aax -codec:a copy -codec:v copy output.mp4
does give me an mp4 file that works, but I like it to be exactly the same m4b as the original just without the encryption.
What command would you propose?
Hello ...
I'm having the same issue as issue #27
:
2018-05-05 21:10:17-0400 Decoding ./fooBar.aax with auth code XXXXXXXX... <-- My auth code goes here.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1dfbac0] [aax] mismatch in checksums!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1dfbac0] error reading header
./fooBar.aax: Invalid data found when processing input
linux$ ffmpeg -version # In /usr/bin/ffmpeg
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (GCC)
configuration: --arch=x86_64 --bindir=/usr/bin --datadir=/usr/share/ffmpeg --disable-debug --disable-static --disable-stripping --enable-avfilter --enable-avresample --enable-bzlib --enable-decklink --enable-doc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gpl --enable-iconv --enable-libass --enable-libbluray --enable-libcdio --enable-libdc1394 --enable-libdrm --enable-libfdk-aac --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-librtmp --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --enable-libxvid --enable-libzvbi --enable-lv2 --enable-lzma --enable-libndi_newtek --enable-nonfree --enable-openal --enable-opencl --enable-opengl --enable-postproc --enable-pthreads --enable-sdl2 --enable-shared --enable-version3 --enable-xlib --enable-zlib --extra-cflags=-I/usr/include/cuda --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables' --prefix=/usr --shlibdir=/usr/lib64 --enable-cuda --enable-cuvid --enable-libnpp --enable-nvdec --enable-nvenc --enable-runtime-cpudetect
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
linux$ lame --version # In /usr/bin/lame
LAME 64bits version 3.100 (http://lame.sf.net)
Copyright (c) 1999-2011 by The LAME Project
Copyright (c) 1999,2000,2001 by Mark Taylor
Copyright (c) 1998 by Michael Cheng
Copyright (c) 1995,1996,1997 by Michael Hipp: mpglib
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program. If not, see
<http://www.gnu.org/licenses/>.
I don't know how to debug this. Any ideas?
Thank you in advance! :)
I used audible-activator to get the AUTHCODE and I used that code. The output was:
$bash AAXtoMP3.sh MY/AUDIBLE/AUTH=CODE audiobook.aax
2017-04-14 14:58:33-0600 Decoding audiobook.aax with auth code MY/AUDIBLE/AUTH=CODE...
Am I doing this right? Audible Activator gave a code in that format. The part after the = was on another line though which worried me. It seemed like it gave me 2 codes but i tried both separately as well. I would show you the code itself but I don't know how sensitive they are.
Using -ss
/-to
together with -acodec copy
breaks the length of the files on some encoding (e.g. flac). Each chapter is the same length as the full file, but it is split correctly.
Every file also hast bugged bitrate metadata.
Reference: https://superuser.com/questions/685562/cutting-videos-with-ffmpeg-length-not-accurate
See pull request: #75
Hi,
when I run the command there is this ambiguous INFO message:
INFO: Sorry, missing or empty "" found, skipping.
It's very hard to tell what that actually means.
Everything appears to successfully run, however i'm receiving this output - not sure if it's a bug or not.
Starting AAXtoMP3.pl...
stdout:
stderr: ffprobe version 2.8.6 Copyright (c) 2007-2016 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.6 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libvpx --enable-vda
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffd84000000] [aax] file checksum == xxxxxxx
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffd84000000] [aax] activation_bytes option is missing!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffd84000000] stream 0, timescale not set
[mjpeg @ 0x7ffd84800000] Changeing bps to 8
[aac @ 0x7ffd8400c400] Number of bands (48) exceeds limit (42).
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/admin/Desktop/name.aax':
Specifically
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffd84000000] [aax] activation_bytes option is missing!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffd84000000] stream 0, timescale not set
[mjpeg @ 0x7ffd84800000] Changeing bps to 8
[aac @ 0x7ffd8400c400] Number of bands (48) exceeds limit (42).
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/admin/Desktop/name.aax':
Is this an issue that should be opened with FFMPEG?
Hi! Great script, works very well except for small annoyance:
BOOK_NAME - Chapter 1.mp3
BOOK_NAME - Chapter 10.mp3
It breaks sorting, would be great to pad numbers to 01, 02 .. etc so that the ordering of the chapters is proper. Thanks!
Hello,
if ffplay is not installed I had problem to conver aax to mp3. The recoding just stoped right after the start without the message. After the installation of ffplay errror was solved. Using Ubuntu 16.
Hi,
just a quality of life change. I had some trouble with different ffmpeg versions and whatever I had installed, before I actually had the right one, gave me:
user@PC:/mnt/d/Projects/AAXtoMP3$ bash AAXtoMP3 MYCODE The_5_Second_Rule.aax
INFO: Sorry, missing or empty "" found, skipping.
2018-06-17 23:20:47+0200 Decoding The_5_Second_Rule.aax with auth code MYCODE...
But no file was created.
As I read from the documentation ("Both formats are chaptered") .m4b files should encode the chapters, right? I don't mean the -c option which spits out individual files for each chapter, but that a single .m4b file contains the information about chapters, like the .aax file does.
However when I listen to my resulting m4b file in iTunes, VLC or IINA or the iBooks app on iOS, the player doesn't seem to recognize any chapters and just plays it like one long audio file.
Chapters are very nice to have since that way you can keep an eye your progress and also use the "play until chapter ends" functionality. The official Audible app provides this functionality and I am wondering why the m4b files don't.
Is this an issue of the player software or the m4b file or am I understanding things wrong completely?
Thanks
Take extracted cover.jpg and embed it into each individual file for cleaner directory structure and player compatibility.
Hi,
the script does not enter the for path
loop when I put my auth code into ~/.authcode.
Steps to reproduce:
Expected result: Script decodes
Actual result: Script exits immediately, nothing happens
[flac @ 0x7fa20f024e00] only one stream is supported Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Title incorrectly set on the resultant output file. Needs to be a combination of title and some other field.
Hi, I was disappointed with chapter encoding only using 15% of my CPU, so I added & to line 145 like so:
</dev/null ffmpeg -loglevel error -stats -i "${full_file_path}" -i "${cover_path}" -ss "${start%?}" -to "${end}" -map 0:0 -map 1:0 -acodec copy ${id3_version_param} \
-metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" -metadata track="${chapternum}" -metadata title="${chapter_title}" \
"${chapter_file}" &
and it uses the entire CPU for this portion of the process by backgrounding each ffmpeg command and immediately starting the next one, causing the overall script to finish about three times faster. It's a huge improvement! However, the output is messy because of the ffmpeg commands logging simultaneously, and the script doesn't finish neatly in terminal after the work is complete.
I am raising an issue since I would like to figure out the best way to incorporate this feature into the project.
This is fantastic software, thank you. Now I can finally listen to my books where I want.
I didn't encounter a problem converting a book:
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
I think this is because the book's title is "We didn't mean to go to sea" and it choked on that single quote. All the files have come out named "We.mp3", "We*.mp3"
Any words of wisdom? Is this a known issue?
The timing on the files is incorrect
Provide option to ignore command rm "${full_file_path}
at the end.
Is it possible to set the bitrate? (It defaults to 64kb/s... is it possible to set an option to convert at 128Kb/s)?
I have a book that has 471 chapters in it. When I pass it through this script the resulting file only has 255 chapters. With the last chapter being the length of the rest of the audiobook. I was wondering if this a limitation of the M4A container or the script?
Here's a script I hacked to suit my preferences. Seems to be working fine. I also have it saving to ~/Audiobooks/Author - Book Title/ instead of a 2nd folder being nested under the author's name.
#!/usr/bin/env bash
AUTHCODE=1234567890
while [ $# -gt 0 ]; do
FILE=$1
echo "Decoding $FILE with AUTHCODE $AUTHCODE..."
ffmpeg -i "$FILE" 2> tmp.txt
TITLE=`grep -a -m1 -h -r "title" tmp.txt | head -1 | cut -d: -f2- | xargs -0`
TITLE=`echo $TITLE | sed -e 's/(Unabridged)//' | xargs -0`
ARTIST=`grep -a -m1 -h -r "artist" tmp.txt | head -1 | cut -d: -f2- | xargs`
GENRE=`grep -a -m1 -h -r "genre" tmp.txt | head -1 | cut -d: -f2- | xargs`
BITRATE=`grep -a -m1 -h -r "bitrate" tmp.txt | head -1 | rev | cut -d: -f 1 | rev | egrep -o [0-9]+ | xargs`
BITRATE="${BITRATE}k"
OUTPUT=`echo $TITLE | sed -e 's/\:/-/g' | xargs -0`
OUTPUT_DIR="$HOME/Audiobooks/${ARTIST} - ${TITLE}"
ffmpeg -v error -stats -activation_bytes $AUTHCODE -i "${FILE}" -vn -c:a libmp3lame -ab $BITRATE "${OUTPUT}.mp3"
echo "Created ${OUTPUT}.mp3."
mkdir -p "${OUTPUT_DIR}"
while read -r first _ _ start _ end; do
if [[ $first = Chapter ]]; then
read
read _ _ chapter
fi
done < tmp.txt
mv "${OUTPUT}.mp3" "${OUTPUT_DIR}"
rm tmp.txt
echo "Extracting cover into ${OUTPUT_DIR}/cover.jpg..."
ffmpeg -v error -activation_bytes $AUTHCODE -i "$FILE" -an -vcodec copy "${OUTPUT_DIR}/cover.jpg"
echo "Done."
shift
done
Thanks for making this. Very useful!
Expected output:
"./Audiobook/Author Name/Book Name/Book Name.mp3"
Actual output:
"./ Audiobook/ Author Name/ Book Name/ Book Name.mp3"
Hi,
for 1.0 release you've used the v1.0
tag, but now for the 1.1
release you dropped the v
and used 1.1
. This breaks automated package bumps, so you should avoid that in the future ;).
Thanks again for the great software.
Hey there! I think it's nicer (quality wise) and faster (cpu wise) to just remove the DRM without reencoding to different formats. I wrote this script for it:
input="input.aax"
EXT2="m4a"
json=$(ffprobe -activation_bytes secret -i "$input" -loglevel error -print_format json -show_format -show_chapters)
target=$(echo $json | jq -r ".format.tags | .date + \" \" + .artist + \" - \" + .title")
title=$(echo $json | jq -r ".format.tags.title")
count=$(echo $json | jq ".chapters | length")
echo "$target"
mkdir "$target"
ffmpeg -activation_bytes secret -i $input -vframes 1 -f image2 "$target/cover.jpg"
echo "[playlist]
NumberOfEntries=$count" > "$target/0_Playlist.pls"
for i in $(seq -w 1 $count); #seq -w adds leading zeros
do
#echo "Welcome $i times"
j=$((10#$i)) # removes leading zeros
n=$(($j-1)) # index in jq (json query) starts with 0, need to subtract 1 from loop index [1 to count])
start=$(echo $json | jq -r ".chapters[$n].start_time")
end=$(echo $json | jq -r ".chapters[$n].end_time")
name=$(echo $json | jq -r ".chapters[$n].tags.title")
ffmpeg -activation_bytes secret -i $input -vn -acodec copy -map_chapters -1 -ss $start -to $end -metadata title="$title $name" "$target/$i $name.$EXT2"
#connot add cover using ffmpeg, open bug: https://trac.ffmpeg.org/ticket/2798 - adding cover in seperate step with seperate tool:
mp4art --add "$target/cover.jpg" "$target/$i $name.$EXT2"
echo "File$j=$i $name.$EXT2" >> "$target/0_Playlist.pls"
done
Hi,
just FYI, this also works on the Windows Subsystem for Linux, not only OSX :)
Tested on Ubuntu 16.04.3 LTS on Windows 10 Pro 1803
sudo apt-get update
)bash --version
4.3.48(1)-release
sudo apt-get install ffmpeg
)ffmpeg --version
2.8.14-0ubuntu0.16.04.1
Also tested on Debian GNU/Linux 9.3 (stretch) on Windows 10 Pro 1803
sudo apt-get update
bash --version
4.4.12(1)-release
sudo apt-get install ffmpeg
)ffmpeg --version
3.2.10-1~deb9u1
Hi,
Not a product issue but I am getting a Linux filename limitation -
mkdir: cannot create directory โ/home/name/temp/Audiobook/author name/extremeeammlllylooongtitleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee and sub title': File name too long
Maybe a fix would be to check if the filename is over the limit (255 chars), then cut it?
Would there be any workaround for now? A lot of Audible books have very long descriptive titles.
Note that I've renamed the actual file.aax, but this isn't the issue, obviously.
Thanks a lot.
Hi,
would it be possible to provide options for Bitrate?
As far as I understand I can only choose 64 bit/s for mp3.
An alternative would be to create a flac (multiple GBs :O
) and then convert it to an mp3 (takes about 10 minutes, resulting in a 500MB file with 256bit/s compared to 200MB in 64bit/s
) manually, but an added option would be far user friendlier.
It's also possible, that I don't understand something about AAX-Bitrates.
Titles containing colons result in mkdir returning a protocol error.
The colon should be convert to a "-" or removed entirely.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.