1
votes

Azure Media Services v3 create asset filter returns BadRequest.

Both code and manifest are included below. Asset duration is 00:00:26.4330000

Have tried adjusting the tracks, no tracks. Have tried adjusting the time parameters.

  • Any ideas on what is wrong?

  • Is it possible for the API to report more information on what is wrong?

  • Can a sample be created that shows how to use AssetFilters.CreateOrUpdate with and without track filters?

Code

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;

Manifest

<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

2 Answers

0
votes

There was a known bug that we hit with Asset Filters that was fixed and rolled out to production now. Looks like you may have hit the same bug. The team is working on also fixing this issue in the .NET SDK and rolling it out.

For now, can you first delete any and all old filters created in v3 API. To fix the issue, you need to remove all old asset and global filters first from this account. We had a versioning mis-match on the filters when we moved from preview to GA that caused a mismatch (and thus the error message you are seeing.) You should be able to get a more detailed error message also if you look at the stacktrace. It typically would show a version conflict issue. Let us know what you see in the details of the error.

0
votes

Carlos, Looking at this today for you. Sorry for delay.

I'm using the Postman collection just to see what is going on with the .NET SDK exactly. Looks like the following filer works fine. I think that the issue you are getting is related to the line of code that creates the new PresentationTimeRange. The values for presentaitonWindowDuration and liveBackoffDuration are not needed for a VOD filter. They are only used for live filters. Try using the following.

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"
        }
      ]
    }]
  }
}

I'll double check to see if this is an issue when I run it through the .NET SDK. I think that our issue here may be that the values for presentationTimeRange are all marked as "REQUIRED" in the current Swagger file here:

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