[FFmpeg-devel] support for reading / writing encrypted MP4 files

Michael Niedermayer michaelni at gmx.at
Mon Dec 7 00:38:34 CET 2015


On Sun, Dec 06, 2015 at 03:42:34PM +0000, Eran Kornblau wrote:
> Hi,
> 
> Sorry for spamming, ran some more tests and found a bug in my patch, updated patch file attached.
> The bug was that in case subsample encryption was enabled (the default for AVC) the subsample size
> reported in the 'saiz' atom was wrong - it did not include the size of the IV.
> I originally tested my change by decrypting the file using MP4Box, and playing it, I guess MP4Box 
> doesn't care about this discrepancy...
> 
> In case anyone started reviewing the patch, the fix is in mov_cenc_end_packet, the lines:
>     ctx->auxiliary_info_sizes[ctx->auxiliary_info_entries] =
>         ctx->auxiliary_info_size - ctx->auxiliary_info_subsample_start;
> 
> were changed to:
>     ctx->auxiliary_info_sizes[ctx->auxiliary_info_entries] =
>         AES_CTR_IV_SIZE + ctx->auxiliary_info_size - ctx->auxiliary_info_subsample_start;
> 
> Thanks
> 
> Eran

>  libavformat/Makefile     |    2 
>  libavformat/movenc.c     |   92 +++++++++-
>  libavformat/movenc.h     |   16 +
>  libavformat/movenccenc.c |  410 +++++++++++++++++++++++++++++++++++++++++++++++
>  libavformat/movenccenc.h |   86 +++++++++

>  libavutil/Makefile       |    2 
>  libavutil/aes_ctr.c      |  132 +++++++++++++++
>  libavutil/aes_ctr.h      |   79 +++++++++

changes to libavutil and libavformat should likely be in seperate
patches/commits, more generally any independant changes should be
in seperate patches (i dont know if there are any other changes that
should be split off)


>  8 files changed, 811 insertions(+), 8 deletions(-)
> 4d4e64b516df4d1b2cb518600550f836c94849bb  0001-movenc-support-cenc-common-encryption.patch
> From 7ccfd1f4fcce2b3c301e14bd3173244241b822bd Mon Sep 17 00:00:00 2001
> From: erankor <eran.kornblau at kaltura.com>
> Date: Thu, 3 Dec 2015 11:42:40 +0200
> Subject: [PATCH] movenc: support cenc (common encryption)

fails to build

ffmpeg/libavformat/movenccenc.c: In function ‘auxiliary_info_add_subsample’:
ffmpeg/libavformat/movenccenc.c:61:5: error: unknown type name ‘u_char’
ffmpeg/libavformat/movenccenc.c:73:7: warning: assignment from incompatible pointer type [enabled by default]


also a Changelog entry should probably be added
and if libavformat uses a new feature from libavutil than libavutils
minor version needs to be bumped when that feature is added


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- 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/20151207/0c29cf44/attachment.sig>


More information about the ffmpeg-devel mailing list