使用 Azure 媒体分析进行面部修订演练Redact faces with Azure Media Analytics walkthrough

概述Overview

Azure 媒体修订器是一种 Azure 媒体分析媒体处理器 (MP),可用于在云中进行可缩放的面部修订。Azure Media Redactor is an Azure Media Analytics media processor (MP) that offers scalable face redaction in the cloud. 使用面部修订,可对视频进行修改,使所选个人的面部模糊显示。Face redaction enables you to modify your video in order to blur faces of selected individuals. 用户可能想要在公共安全和新闻媒体场景中使用面部修订服务。You may want to use the face redaction service in public safety and news media scenarios. 对于时长仅几分钟但包含多张面孔的镜头,进行手动面部修订可能需要几个小时,但使用此服务仅需几个简单步骤即可完成该过程。A few minutes of footage that contains multiple faces can take hours to redact manually, but with this service the face redaction process will require just a few simple steps. 有关详细信息,请参阅博客。For more information, see this blog.

有关 Azure Media Redactor 的详细信息,请参阅面部修正概述主题。For details about Azure Media Redactor, see the Face redaction overview topic.

本主题提供分步指导,引导用户使用 Azure 媒体服务资源管理器 (AMSE) 和 Azure Media Redactor Visualizer(开源工具)运行完整修正工作流。This topic shows step by step instructions on how to run a full redaction workflow using Azure Media Services Explorer (AMSE) and Azure Media Redactor Visualizer (open source tool).

有关详细信息,请参阅 这一 博客。For more information, see this blog.

Azure 媒体服务资源管理器工作流Azure Media Services Explorer workflow

使用 Redactor 的最简单方法是使用 GitHub 上的开源 AMSE 工具。The easiest way to get started with Redactor is to use the open source AMSE tool on GitHub. 如果不需要访问批注 json 或 jpg 面部图像,可通过 合并 模式运行简化的工作流。You can run a simplified workflow via combined mode if you don’t need access to the annotation json or the face jpg images.

下载和安装Download and setup

  1. 此处下载 AMSE for AMS v2 工具。Download the AMSE for AMS v2 tool from here.

  2. 使用服务密钥登录媒体服务帐户。Log in to your Media Services account using your service key.

    若要获取帐户名称和密钥信息,请转到 Azure 门户并选择 AMS 帐户。To obtain the account name and key information, go to the Azure portal and select your AMS account. 然后,选择“设置”>“密钥”。Then, select Settings > Keys. 管理密钥窗口会显示帐户名称、主密钥和辅助密钥。The Manage keys windows shows the account name and the primary and secondary keys is displayed. 复制帐户名称和主密钥的值。Copy values of the account name and the primary key.

面部修正

第一步 – 分析模式First pass – analyze mode

  1. 通过“资产”–>“上传”或拖放上传媒体文件。Upload your media file through Asset –> Upload, or via drag and drop.
  2. 右键单击,并使用“媒体分析”–>“Azure Media Redactor”–>“分析模式”处理媒体文件。Right click and process your media file using Media Analytics –> Azure Media Redactor –> Analyze mode.

面部修正

面部修正

输出包括带有面部位置数据的批注 json 文件以及检测到的每张脸的 jpg。The output will include an annotations json file with face location data, as well as a jpg of each detected face.

面部修正

第二步 – 修正模式Second pass – redact mode

  1. 将原始视频资产上传到第一步中的输出,并设置为主要资产。Upload your original video asset to the output from the first pass and set as a primary asset.

    面部修正

  2. (可选)上传“Dance_idlist.txt”文件,它包含要修订的 ID 的换行符分隔列表。(Optional) Upload a 'Dance_idlist.txt' file which includes a newline delimited list of the IDs you wish to redact.

    面部修订

  3. (可选)编辑 annotations.json 文件,例如增加边界框边界。(Optional) Make any edits to the annotations.json file such as increasing the bounding box boundaries.

  4. 右键单击第一步中的输出资产,选择“Redactor”,在“修正” 模式下运行。Right click the output asset from the first pass, select the Redactor, and run with the Redact mode.

    面部修正

  5. 下载或共享最终修正的输出资产。Download or share the final redacted output asset.

    面部修正

Azure Media Redactor Visualizer 开源工具Azure Media Redactor Visualizer open source tool

有一开源 可视化工具 ,可帮助开发人员通过批注格式分析和使用输出。An open source visualizer tool is designed to help developers just starting with the annotations format with parsing and using the output.

克隆存储库后,若要运行项目,需要从其 官方网站下载 FFMPEG。After you clone the repo, in order to run the project, you will need to download FFMPEG from their official site.

如果开发人员要分析 JSON 批注数据,可在 Models.MetaData 内查看样本代码示例。If you are a developer trying to parse the JSON annotation data, look inside Models.MetaData for sample code examples.

设置工具Set up the tool

  1. 下载并生成整个解决方案。Download and build the entire solution.

    面部修正

  2. 此处下载 FFMPEG。Download FFMPEG from here. 此项目最初使用具有静态链接的版本 be1d324 (2016-10-04) 开发。This project was originally developed with version be1d324 (2016-10-04) with static linking.

  3. 将 ffmpeg.exe 和 ffprobe.exe 复制到与 AzureMediaRedactor.exe 相同的输出文件夹。Copy ffmpeg.exe and ffprobe.exe to the same output folder as AzureMediaRedactor.exe.

    面部修正

  4. 运行 AzureMediaRedactor.exe。Run AzureMediaRedactor.exe.

使用工具Use the tool

  1. 在分析模式下使用 Redactor MP 在 Azure 媒体服务帐户中处理视频。Process your video in your Azure Media Services account with the Redactor MP on Analyze mode.

  2. 下载原始视频文件和修正 - 分析作业的输出。Download both the original video file and the output of the Redaction - Analyze job.

  3. 运行可视化工具应用程序并选择上述文件。Run the visualizer application and choose the files above.

    面部修正

  4. 预览文件。Preview your file. 通过右侧边栏选择要进行模糊处理的人脸。Select which faces you'd like to blur via the sidebar on the right.

    面部修正

  5. 将更新底部文本字段,使其带有面部 ID。The bottom text field will update with the face IDs. 创建名为“idlist.txt”的文件,将这些 ID 作为换行符分隔列表。Create a file called "idlist.txt" with these IDs as a newline delimited list.

    备注

    idlist.txt 应保存在 ANSI 中。The idlist.txt should be saved in ANSI. 可以使用记事本保存在 ANSI 中。You can use notepad to save in ANSI.

  6. 将此文件上传到步骤 1 中的输出资产。Upload this file to the output asset from step 1. 也将原始视频上传到此资产并设置为主要资产。Upload the original video to this asset as well and set as primary asset.

  7. 在“修正”模式下对此资产运行修正作业,以获取最终修正的视频。Run Redaction job on this asset with "Redact" mode to get the final redacted video.

后续步骤Next steps

媒体服务 v3(最新版本)Media Services v3 (latest)

查看最新版本的 Azure 媒体服务!Check out the latest version of Azure Media Services!

媒体服务 v2(旧版)Media Services v2 (legacy)

Azure 媒体服务分析概述Azure Media Services Analytics Overview

Azure 媒体分析演示Azure Media Analytics demos

宣布推出 Azure 媒体分析的面部修订Announcing Face Redaction for Azure Media Analytics