FFmpeg:如何制作MP4 CENC(通用加密)视频 [英] FFmpeg: how to produce MP4 CENC (Common Encryption) videos

查看:1632
本文介绍了FFmpeg:如何制作MP4 CENC(通用加密)视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用ffmpeg进行CENC加密的正确语法是什么?

What is the correct syntax to do CENC encryption with ffmpeg?

ffmpeg 3.0发行说明包括通用加密(CENC)MP4编码和解码支持",并且文件libavformat/movenccenc.h和libavformat/movenccenc.c似乎包括根据通用加密对MP4文件进行加密所需的所有内容.标准.

The ffmpeg 3.0 release notes include "Common Encryption (CENC) MP4 encoding and decoding support", and the files libavformat/movenccenc.h and libavformat/movenccenc.c seem to include everything needed to encrypt MP4 files according to the Common Encryption standard.

但是,在ffmpeg手册页中找不到关于此主题的任何文档.

However, I can't find any documentation on this topic in the ffmpeg manual pages.

致谢

推荐答案

Mulvya的答案涵盖了ffmpeg-options.

Mulvya's answer covered the ffmpeg-options.

就像我昨天(独立地)做一些实验一样,我只是添加一个具体的示例并谈论回放.

I'm just adding a concrete example and talk about playback too, as i did some experiments yesterday (independently).

ffmpeg -i SampleVideo_1280x720_1mb.mp4 -vcodec copy -acodec copy -encryption_scheme cenc-aes-ctr -encryption_key 76a6c65c5ea762046bd749a2e632ccbb -encryption_kid a7e61c373e219033c21091fa607bf3b8 SampleVideo_1280x720_1mb_encrypted.mp4

(当然,根据您的情况,用法可能有所不同;我只是重新混合了视频和音频)

(of course usage might be different for your case; i just remuxed video and audio)

ffplay

ffplay SampleVideo_1280x720_1mb_encrypted.mp4 -decryption_key 76a6c65c5ea762046bd749a2e632ccbb

但是由于这或多或少是一个原型播放器,所以人们可能想使用更强大的功能.

But as this is more or less a prototype-player, one might want to use something more powerful.

mpv

mpv --demuxer-lavf-o=decryption_key=76a6c65c5ea762046bd749a2e632ccbb SampleVideo_1280x720_1mb_encrypted.mp4

此处进行了一些讨论,因为我的第一个预期命令行没有表现出预期!

There is some discussion here as my first expected command-line did not behave as expected!

编辑:尝试解决Reino的问题

trying to address Reino's questions

encryption_key仅为128位= 16字节编码为十六进制(遵循 random.org 的配置为16个字节,并且hex.encoding是有效的密钥(但我通常不建议您信任外部资源).我使用python的秘密模块归结为:secrets.token_hex(16) . encryption_key将需要用于解码.

The encryption_key is just 128 bit = 16 bytes encoded as Hex (following the usage of AES-128-CTR). So random.org with a configuration of 16 bytes and hex.encoding would be a valid key (but i'm not recommending to trust external resources in general). I used python's secrets module which boils down to: secrets.token_hex(16). This encryption_key will be needed for decoding.

encryption_kid 密钥ID 只是该键的标识符,可能是更复杂的使用模式所需要的(我!是在猜测!您可以执行以下操作:嘿视频...我需要我的1000个键中的哪一个? ).我想必须通过它,但是解码不是必需的(如果您知道对哪个视频使用哪个密钥).

The encryption_kid Key ID is just an identifier for this key, probably needed for more complex usage-patterns (i'm !guessing! you could do something like: hey video... which of my 1000 keys do i need for you?). I suppose it's mandatory to pass it, but it's not required for decoding (if you know which key to use for which video).

官方参考为:

  • 标准
  • ffmpeg实现:文档(可通过命令行获取)或简短的
  • Standard
  • ffmpeg implementation: docs (available through command-line) or a short extraction

这篇关于FFmpeg:如何制作MP4 CENC(通用加密)视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆