Azure Video Indexer 示例项目教程
1. 项目目录结构及介绍
azure-video-indexer-samples/
├── API-Samples/
│ ├── C#/
│ ├── Python/
│ └── ...
├── BringYourOwn-Samples/
│ ├── ...
│ └── ...
├── Deploy-Samples/
│ ├── ARM/
│ ├── Bicep/
│ └── ...
├── Embedding widgets/
│ ├── ...
│ └── ...
├── LogicApp-Samples/
│ ├── ...
│ └── ...
├── VideoIndexerEnabledByArc/
│ ├── ...
│ └── ...
├── VideoQnA-Demo/
│ ├── ...
│ └── ...
├── media/
│ ├── ...
│ └── ...
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
└── SECURITY.md
目录结构介绍
- API-Samples: 包含使用不同编程语言(如C#、Python等)的API示例代码。
- BringYourOwn-Samples: 包含自定义示例代码,展示如何将Video Indexer集成到现有产品中。
- Deploy-Samples: 包含使用ARM或Bicep进行资源部署的示例。
- Embedding widgets: 展示如何将Video Indexer的嵌入式小部件添加到应用程序中。
- LogicApp-Samples: 包含使用逻辑应用的示例。
- VideoIndexerEnabledByArc: 包含通过Arc启用的Video Indexer示例。
- VideoQnA-Demo: 包含视频问答演示的示例。
- media: 包含用于Markdown文件的媒体文件。
- .gitignore: 定义在提交时忽略的文件。
- CODE_OF_CONDUCT.md: 行为准则文件。
- CONTRIBUTING.md: 贡献指南文件。
- LICENSE: 项目许可证文件。
- README.md: 项目自述文件。
- SECURITY.md: 安全策略文件。
2. 项目启动文件介绍
在API-Samples
目录下,每个子目录(如C#、Python等)都包含一个启动文件,用于演示如何使用Video Indexer API上传和索引视频。例如,在API-Samples/C#/
目录下,可能会有一个Program.cs
文件,这是C#示例的启动文件。
示例启动文件
// API-Samples/C#/Program.cs
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace AzureVideoIndexerSample
{
class Program
{
static async Task Main(string[] args)
{
// 初始化HttpClient
var client = new HttpClient();
// 设置API密钥
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "YOUR_API_KEY");
// 上传视频并索引
var response = await client.PostAsync("https://api.videoindexer.ai/videos", new StringContent("video_url"));
// 处理响应
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
}
3. 项目的配置文件介绍
在Deploy-Samples
目录下,通常会有一个配置文件,用于定义资源部署的参数。例如,在Deploy-Samples/ARM/
目录下,可能会有一个azuredeploy.json
文件,这是ARM模板的配置文件。
示例配置文件
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The location in which the resources will be deployed."
}
},
"videoIndexerAccountName": {
"type": "string",
"metadata": {
"description": "The name of the Video Indexer account."
}
}
},
"resources": [
{
"type": "Microsoft.VideoIndexer/accounts",
"apiVersion": "2021-01-01",
"name": "[parameters('videoIndexerAccountName')]",
"location": "[parameters('location')]",
"properties": {}
}
]
}
这个配置文件定义了部署Video Indexer账户所需的参数和资源。