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

Eran Kornblau eran.kornblau at kaltura.com
Sun Dec 6 16:42:34 CET 2015


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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-movenc-support-cenc-common-encryption.patch
Type: application/octet-stream
Size: 33056 bytes
Desc: 0001-movenc-support-cenc-common-encryption.patch
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151206/59ce66dd/attachment.obj>

More information about the ffmpeg-devel mailing list