【问题标题】:AWS Lambda elastic transcoder key encrypted HLS with playlistAWS Lambda 弹性转码器密钥加密 HLS 与播放列表
【发布时间】:2018-07-20 02:16:12
【问题描述】:

我想将视频自动转码为带有播放列表的加密 hls。 我的 lambda 代码如下,但运行时出现以下错误

{ ValidationException: The MD5 hash of the base64-decoded value for 
''Encryption:Key'' must equal the base64-decoded value for ''Encryption:KeyMd5''.

lambda中的代码是

var srcKey =  decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, " ")); 
 var newKey = key.split('.')[0];
 var plainEncryptionKey='t6w9z$C&F)J@NcQf';
 var KeyBase64 = new Buffer(plainEncryptionKey).toString('base64');
 console.log("plain_base64: " + KeyBase64);

 var crypto = require('crypto');
 var MD5= crypto.createHash('md5').update(plainEncryptionKey).digest("hex");
 var MD5Base64 = new Buffer(MD5).toString('base64');
 console.log("md5_base64: " + MD5Base64);


 var params = {
  PipelineId: pipelineId,
  OutputKeyPrefix: newKey + '/',
  Input: {
   Key: srcKey,
   FrameRate: 'auto',
   Resolution: 'auto',
   AspectRatio: 'auto',
   Interlaced: 'auto',
   Container: 'auto'
  },
  Outputs: [{
   Key: newKey + '-hls' + '.ts',
   ThumbnailPattern: '',
   PresetId: '1351620000001-200010', //HLS v3 2mb/s
   SegmentDuration: '10',
  }],
    Playlists: [
    {
      Name: 'index',
      Format: 'HLSv3',
      OutputKeys: [ newKey + '-hls' + '.ts',  ],
      HlsContentProtection: {
        InitializationVector: 'VQMKGVjivkBUJLf4BY4uQQ==',
        Key: KeyBase64,
        KeyMd5: MD5Base64,
        KeyStoragePolicy: 'NoStore',
        LicenseAcquisitionUrl: 'https://example.com/ekey.php',
        Method: 'aes-128'
      },
    },

我忽略了什么? 我唯一能想到的我想念的是我首先需要加密明码......但是有什么建议吗?

【问题讨论】:

    标签: aws-lambda amazon-elastic-transcoder


    【解决方案1】:

    看来MD5的生成是错误的,我需要这样做:

    var MD5Base64= crypto.createHash('md5').update(encKey).digest("base64");
    

    这将创建 MD5 并使用 base64 对其进行编码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-30
      • 1970-01-01
      • 2018-11-11
      • 2012-12-08
      • 2016-03-29
      • 2022-08-19
      • 1970-01-01
      相关资源
      最近更新 更多