Azure Media Services v3创建资产筛选器返回BadRequest

时间:2018-11-06 16:18:30

标签: azure-media-services

Azure Media Services v3创建资产过滤器返回BadRequest。

以下均包含代码和清单。资产持续时间为00:00:26.4330000

尝试调整轨道,没有轨道。 尝试调整时间参数。

  • 关于哪里出了什么问题的任何想法?

  • API是否有可能报告有关错误原因的更多信息?

  • 是否可以创建一个示例,说明如何使用带或不带跟踪过滤器的AssetFilters.CreateOrUpdate?

代码

var timingData = GetManifestTimingData(new Uri(asset.ManifestUrl));
Log.Info($"Timescale: {timingData.TimeScale} Offset: {timingData.TimestampOffset} clip: ( {TimeSpan.FromSeconds(startTimeSec)} - {TimeSpan.FromSeconds(endTimeSec)} ) as ( {TimeSpan.FromSeconds(startTimeSec)} to {TimeSpan.FromSeconds(endTimeSec)} ) {name} ----- {asset.ToAssetInfo()?.hashKey} {asset.Name} -- Manifest: {asset.PlaybackUrl}");

if (startTimeSec >= timingData.AssetDuration.TotalSeconds)
{
    Log.Error($"Invalid start time: {startTimeSec} > {timingData.AssetDuration}");
    return null;
}

if (endTimeSec >= timingData.AssetDuration.TotalSeconds)
{
    endTimeSec = (int)Math.Floor(timingData.AssetDuration.TotalSeconds);
}

var startTimeSpan = timingData.OffSetAsTimeSpan + TimeSpan.FromSeconds(startTimeSec);
var endTimeSpan = timingData.OffSetAsTimeSpan + TimeSpan.FromSeconds(endTimeSec);

double timeScale = timingData.TimeScale ?? TimeSpan.TicksPerSecond;

var scaledStartTime = Convert.ToInt64(Math.Truncate(startTimeSpan.Ticks * (timeScale / TimeSpan.TicksPerSecond)));
var scaledEndTime = Convert.ToInt64(Math.Truncate(endTimeSpan.Ticks * (timeScale / TimeSpan.TicksPerSecond)));

var range = new PresentationTimeRange(scaledStartTime, scaledEndTime, 9223372036854775807, 0, (long)timeScale, false);

var tracks = new List<FilterTrackSelection>
    {
        new FilterTrackSelection(new List<FilterTrackPropertyCondition>
        {
            new FilterTrackPropertyCondition(FilterTrackPropertyType.Type, "Audio", FilterTrackPropertyCompareOperation.Equal),
        }),
        new FilterTrackSelection(new List<FilterTrackPropertyCondition>
        {
            new FilterTrackPropertyCondition(FilterTrackPropertyType.Type, "Video", FilterTrackPropertyCompareOperation.Equal),
        }),
    };

var firstQuality = new FirstQuality(128000);

var filterParams = new AssetFilter(null, name, FilterType, range, firstQuality, tracks);

var filter = _client.AssetFilters.CreateOrUpdate(ResourceGroup, AccountName, asset.Id, name, filterParams);
if (filter == null)
{
    Log.Warn($"Failed to create filter {name} in {asset}");
    return null;
}

return filter;

清单

<SmoothStreamingMedia MajorVersion="2" MinorVersion="2" Duration="264333333" TimeScale="10000000">
<StreamIndex Chunks="13" Type="video" Url="QualityLevels({bitrate})/Fragments(video={start time})" QualityLevels="1">
    <QualityLevel Index="0" Bitrate="770760" FourCC="H264" MaxWidth="1280" MaxHeight="720" CodecPrivateData="000000016764001FACD9405005BA10000003001000000303C0F18319600000000168EBECB22C" />
    <c t="0" d="20333333" r="2" />
    <c d="20333334" />
    <c d="20333333" r="2" />
    <c d="20333334" />
    <c d="20333333" r="2" />
    <c d="20333334" />
    <c d="20333333" r="2" />
    <c d="20333334" />
    <c d="20333333" />
</StreamIndex>
<StreamIndex Chunks="14" Type="audio" Url="QualityLevels({bitrate})/Fragments(aac_UND_2_127999={start time})" QualityLevels="1" Name="aac_UND_2_127999">
    <QualityLevel AudioTag="255" Index="0" BitsPerSample="16" Bitrate="127999" FourCC="AACL" CodecPrivateData="1190" Channels="2" PacketSize="4" SamplingRate="48000" />
    <c t="0" d="20053333" r="2" />
    <c d="20053334" />
    <c d="20053333" r="2" />
    <c d="20053334" />
    <c d="20053333" r="2" />
    <c d="20053334" />
    <c d="20053333" r="2" />
    <c d="20053334" />
    <c d="20053333" />
    <c d="3626667" />
</StreamIndex>
<Protection>
    <ProtectionHeader SystemID="B47B251A-2409-4B42-958E-08DBAE7B4EE9">
    <ContentProtection schemeIdUri="urn:mpeg:dash:sea:2012" xmlns:sea="urn:mpeg:dash:schema:sea:2012">
        <sea:SegmentEncryption schemeIdUri="urn:mpeg:dash:sea:aes128-cbc:2013" />
        <sea:KeySystem keySystemUri="urn:mpeg:dash:sea:keysys:http:2013" />
        <sea:CryptoPeriod IV="0xF6BCAD06C97D0FEC81B702C86183355B" keyUriTemplate="https://testurstream.keydelivery.westus.media.azure.net?kid=d6c1f008-d43f-4c60-926f-76ba613b7b4b" />
    </ContentProtection>
    </ProtectionHeader>
</Protection>
</SmoothStreamingMedia>

2 个答案:

答案 0 :(得分:0)

我们使用资产过滤器发现了一个已知的错误,该错误已修复并现已投入生产。看起来您可能遇到了相同的错误。该团队还致力于在.NET SDK中修复此问题并将其推出。

现在,您可以先删除在v3 API中创建的所有旧过滤器吗?要解决此问题,您需要先从该帐户中删除所有旧资产和全局过滤器。当我们从预览移到GA时,过滤器上的版本控制不匹配,导致不匹配(并因此导致了您看到的错误消息。)如果您查看stacktrace,也应该可以获得更详细的错误消息。它通常会显示版本冲突问题。让我们知道您在错误详细信息中看到的内容。

答案 1 :(得分:0)

卡洛斯, 今天为您看这个。不好意思推迟了。

我正在使用Postman集合只是为了了解.NET SDK到底发生了什么。 看起来以下文件管理器工作正常。我认为您遇到的问题与创建新PresentationTimeRange的代码行有关。对于VOD筛选器,无需使用presentaitonWindowDuration和liveBackoffDuration的值。它们仅用于实时过滤器。尝试使用以下内容。

new PresentationTimeRange(scaledStartTime, scaledEndTime, null, null, (long)timeScale, null);

{
  "properties": {
    "presentationTimeRange": {
      "startTimestamp": 0,
      "endTimestamp": 264333333,
      "presentationWindowDuration": null,
      "liveBackoffDuration": null,
      "timescale": 10000000,
      "forceEndTimestamp": null
    },
    "tracks": [{
      "trackSelections": [{
          "property": "Type",
          "operation": "Equal",
          "value": "Video"
        },
        {
          "property": "Type",
          "operation": "Equal",
          "value": "Audio"
        }
      ]
    }]
  }
}

当我通过.NET SDK运行它时,我会仔细检查这是否是一个问题。 我认为我们这里的问题可能是在当前的Swagger文件中,presentationTimeRange的值都被标记为“必需”:

https://github.com/Azure/azure-rest-api-specs/blob/dec75495352902ebb6393d42c50465b6195f239d/specification/mediaservices/resource-manager/Microsoft.Media/stable/2018-07-01/AccountFilters.json#L63