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

Michael Niedermayer michael at niedermayer.cc
Wed Dec 30 19:03:15 CET 2015


On Tue, Dec 29, 2015 at 08:05:28PM +0000, Eran Kornblau wrote:
> > > > > +    case MKTAG('e','n','c','v'):        // encrypted video
> > > > > +    case MKTAG('e','n','c','a'):        // encrypted audio
> > > > > +        id = mov_codec_id(st, format);
> > > > > +        st->codec->codec_id = id;
> > > > 
> > > > this seems missing a check for st->codec->codec_id being "unset"
> > > > before setting it
> > > > 
> > > Will add it
> > > 
> While testing this change, I found that for audio, at this point codec_id is actually already initialized - 
> it gets initialized when ff_mov_read_esds calls ff_mp4_read_dec_config_descr, in this line:
>     st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
> 
> What happens with my current code is that this outputs a warning that frma is ignored because codec_id
> is not none. I think I will just skip the warning when st->codec->codec_id "happens to be" the same as 
> the codec that was inferred by the frma atom.
>  
> This appears to work well:
>     case MKTAG('e','n','c','v'):        // encrypted video
>     case MKTAG('e','n','c','a'):        // encrypted audio
>         id = mov_codec_id(st, format);
>         if (st->codec->codec_id != AV_CODEC_ID_NONE &&
>             st->codec->codec_id != id) {
>             av_log(c->fc, AV_LOG_WARNING,
>                    "ignoring 'frma' atom of '%.4s', stream has codec id %d\n",
>                    (char*)&format, st->codec->codec_id);
>             break;
>         }
> 
>         st->codec->codec_id = id;
>         sc->format = format;
>         break;
> 
> Please let me know if you think that is ok, and I will resubmit the patch with all fixes.

should be ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- 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/20151230/776faf08/attachment.sig>


More information about the ffmpeg-devel mailing list