[FFmpeg-devel] [PATCH v5] Add support for Audible AAX (and AAX+) files

Michael Niedermayer michael at niedermayer.cc
Sat Jul 18 00:44:57 CEST 2015


On Thu, Jul 16, 2015 at 03:57:26AM +0300, Vesselin Bontchev wrote:
> Hi,
> 
> A sample Audible .aax file can be downloaded from the following link,
> 
> https://gitlab.com/vesselin.bontchev/audible-samples/tree/master
> 
> Usage,
> 
> ffmpeg -activation_bytes 62689101 -i Audible_AAX_sample_62689101.aax -vn -c:a copy -v debug output.mp4
> 
> Thanks,
> Vesselin

>  doc/general.texi   |    2 
>  doc/muxers.texi    |    7 +++
>  libavformat/isom.h |    6 ++
>  libavformat/mov.c  |  122 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 137 insertions(+)
> d6cf740b4d4f4193458dbf1d8f4e1d2375eb4501  0001-Add-support-for-Audible-AAX-and-AAX-files.patch
> From 933c6d8fd44ff4683e16fbed9d5ca01253fc9f94 Mon Sep 17 00:00:00 2001
> From: Vesselin Bontchev <vesselin.bontchev at yandex.com>
> Date: Sat, 11 Jul 2015 18:02:47 +0000
> Subject: [PATCH] Add support for Audible AAX (and AAX+) files
> 
> ---
>  doc/general.texi   |   2 +
>  doc/muxers.texi    |   7 +++
>  libavformat/isom.h |   6 +++
>  libavformat/mov.c  | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 137 insertions(+)
> 
> diff --git a/doc/general.texi b/doc/general.texi
> index dc22d90..617be66 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -226,6 +226,8 @@ library:
>  @item 4xm                       @tab   @tab X
>      @tab 4X Technologies format, used in some games.
>  @item 8088flex TMV              @tab   @tab X
> + at item AAX                       @tab   @tab X
> +    @tab Audible Enhanced Audio format, used in audiobooks.
>  @item ACT Voice                 @tab   @tab X
>      @tab contains G.729 audio
>  @item Adobe Filmstrip           @tab X @tab X
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index d75d7de..b5fc598 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -667,6 +667,13 @@ point on IIS with this muxer. Example:
>  ffmpeg -re @var{<normal input/transcoding options>} -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1)
>  @end example
>  
> + at subsection Audible AAX
> +
> +Audible AAX files are encrypted M4B files, and they can be decrypted by specifying a 4 byte activation secret.
> + at example
> +ffmpeg -activation_bytes 1CEB00DA -i test.aax -vn -c:a copy output.mp4
> + at end example
> +
>  @section mp3
>  
>  The MP3 muxer writes a raw MP3 stream with the following optional features:
> diff --git a/libavformat/isom.h b/libavformat/isom.h
> index 5d48989..6ea1da1 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -198,6 +198,12 @@ typedef struct MOVContext {
>      MOVFragmentIndex** fragment_index_data;
>      unsigned fragment_index_count;
>      int atom_depth;
> +    unsigned int aax_mode;  ///< 'aax' file has been detected
> +    uint8_t file_key[20];
> +    uint8_t file_iv[20];
> +    void *activation_bytes;
> +    int activation_bytes_size;
> +    struct AVAES *aes_decrypt;
>  } MOVContext;
>  
>  int ff_mp4_read_descr_len(AVIOContext *pb);
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 9d6b2e4..b248eb7 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -37,6 +37,8 @@
>  #include "libavutil/dict.h"
>  #include "libavutil/display.h"
>  #include "libavutil/opt.h"
> +#include "libavutil/aes.h"
> +#include "libavutil/sha.h"
>  #include "libavutil/timecode.h"
>  #include "libavcodec/ac3tab.h"
>  #include "avformat.h"
> @@ -807,6 +809,116 @@ static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>      return 0; /* now go for moov */
>  }
>  
> +#define DRM_BLOB_SIZE 56
> +
> +static int mov_read_adrm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> +{
> +    // extracted from libAAX_SDK.so and AAXSDKWin.dll files!

> +    uint8_t fixed_key[] = { 0x77, 0x21, 0x4d, 0x4b, 0x19, 0x6a, 0x87, 0xcd,
> +                                  0x52, 0x00, 0x45, 0xfd, 0x20, 0xa5, 0x1d, 0x67 };

I think this should not be hardcoded but provided by the user via
an AVOption


[...]
> @@ -4058,6 +4171,10 @@ static int mov_read_close(AVFormatContext *s)
>      }
>      av_freep(&mov->fragment_index_data);
>  
> +    if (mov->aes_decrypt) {
> +        av_free(mov->aes_decrypt);
> +    }

the if() is unneeded, and av_freep() should be used


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150718/e251c775/attachment.sig>


More information about the ffmpeg-devel mailing list