Azure 媒体服务——使用 Python SDK 创建实时输出和流定位器

Azure Media Services -- Create Live Output and Streaming Locator with Python SDK

我正在开发一个使用 Azure 媒体服务 Python SDK (v3) 的项目。我有以下代码,一旦关联的实时事件是 运行ning:

,它就会创建一个实时输出和一个流定位器
# Step 2: create a live output (used to reference the manifest file)
live_outputs = self.__media_services.live_outputs
config_data_live_output = LiveOutput(asset_name=live_output_name, archive_window_length=timedelta(minutes=30))
output = live_outputs.create(StreamHandlerAzureMS.RESOUCE_GROUP_NAME, StreamHandlerAzureMS.ACCOUNT_NAME, live_event_name, live_output_name, config_data_live_output)

# Step 3: get a streaming locator (the ID of the locator is used in the URL)
locators = self.__media_services.streaming_locators
config_data_streaming_locator = StreamingLocator(asset_name=locator_name)
locator = locators.create(StreamHandlerAzureMS.RESOUCE_GROUP_NAME, StreamHandlerAzureMS.ACCOUNT_NAME, locator_name, config_data_streaming_locator)

self.__media_services 是类型 AzureMediaServices 的对象。当我 运行 上面的代码时,我收到以下异常:

azure.mgmt.media.models._models_py3.ApiErrorException: (ResourceNotFound) Live Output asset was not found.

问题:为什么 Azure 媒体服务在创建资源的操作中抛出此错误?我该如何解决这个问题?

请注意,我已成功使用服务主体对 Azure 媒体服务的 SDK 进行身份验证,并且我可以使用 ffmpeg 成功将视频推送到现场活动。

我建议您快速浏览一下本教程中的现场活动流程,不幸的是,它是在 .NET 中。我们仍在努力更新 Python 个样本。

https://docs.microsoft.com/en-us/azure/media-services/latest/stream-live-tutorial-with-api

但它应该有助于解决这个问题。我看到的第一个问题是您可能没有为要录制到的实时输出创建资产。

您可以将 Live Outputs 视为“录音机”机器,将资产视为磁带。它们是磁带录音机将要写入的存储帐户中的位置。

因此,在您举办现场活动后 运行,您最多可以让这些“录音机”中的 3 个运行并写入存储中的 3 个不同“磁带”(资产)。

  1. 创建空资产
  2. 创建实时输出并将其指向该资产
  3. 获取该资产的流媒体定位器 - 这样您就可以观看录像带了。请注意,您正在为您在步骤 1 中创建的资产创建流媒体定位器。将其视为“我想看这个磁带”而不是“我想看这个录音机”。