Skip to content

azurermMediaAssetFilter

Manages an Azure Media Asset Filter.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "media-resources",
  }
);
const azurermStorageAccountExample = new azurerm.storageAccount.StorageAccount(
  this,
  "example_1",
  {
    account_replication_type: "GRS",
    account_tier: "Standard",
    location: azurermResourceGroupExample.location,
    name: "examplestoracc",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageAccountExample.overrideLogicalId("example");
const azurermMediaServicesAccountExample =
  new azurerm.mediaServicesAccount.MediaServicesAccount(this, "example_2", {
    location: azurermResourceGroupExample.location,
    name: "examplemediaacc",
    resource_group_name: azurermResourceGroupExample.name,
    storage_account: [
      {
        id: azurermStorageAccountExample.id,
        is_primary: true,
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMediaServicesAccountExample.overrideLogicalId("example");
const azurermMediaAssetExample = new azurerm.mediaAsset.MediaAsset(
  this,
  "example_3",
  {
    description: "Asset description",
    media_services_account_name: azurermMediaServicesAccountExample.name,
    name: "Asset1",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMediaAssetExample.overrideLogicalId("example");
const azurermMediaAssetFilterExample =
  new azurerm.mediaAssetFilter.MediaAssetFilter(this, "example_4", {
    asset_id: azurermMediaAssetExample.id,
    first_quality_bitrate: 128000,
    name: "Filter1",
    presentation_time_range: [
      {
        end_in_units: 15,
        force_end: false,
        live_backoff_in_units: 0,
        presentation_window_in_units: 90,
        start_in_units: 0,
        unit_timescale_in_miliseconds: 1000,
      },
    ],
    track_selection: [
      {
        condition: [
          {
            operation: "Equal",
            property: "Type",
            value: "Audio",
          },
          {
            operation: "NotEqual",
            property: "Language",
            value: "en",
          },
          {
            operation: "NotEqual",
            property: "FourCC",
            value: "EC-3",
          },
        ],
      },
      {
        condition: [
          {
            operation: "Equal",
            property: "Type",
            value: "Video",
          },
          {
            operation: "Equal",
            property: "Bitrate",
            value: "3000000-5000000",
          },
        ],
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMediaAssetFilterExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • assetId - (Required) The Asset ID for which the Asset Filter should be created. Changing this forces a new Asset Filter to be created.

  • name - (Required) The name which should be used for this Asset Filter. Changing this forces a new Asset Filter to be created.


  • firstQualityBitrate - (Optional) The first quality bitrate. Sets the first video track to appear in the Live Streaming playlist to allow HLS native players to start downloading from this quality level at the beginning.

  • presentationTimeRange - (Optional) A presentationTimeRange block as defined below.

  • trackSelection - (Optional) One or more trackSelection blocks as defined below.


A presentationTimeRange block supports the following:

  • endInUnits - (Optional) The absolute end time boundary. Applies to Video on Demand (VoD). For the Live Streaming presentation, it is silently ignored and applied when the presentation ends and the stream becomes VoD. This is a long value that represents an absolute end point of the presentation, rounded to the closest next GOP start. The unit is defined by unitTimescaleInMiliseconds, so an endInUnits of 180 would be for 3 minutes. Use startInUnits and endInUnits to trim the fragments that will be in the playlist (manifest). For example, startInUnits set to 20 and endInUnits set to 60 using unitTimescaleInMiliseconds in 1000 will generate a playlist that contains fragments from between 20 seconds and 60 seconds of the VoD presentation. If a fragment straddles the boundary, the entire fragment will be included in the manifest.

  • forceEnd - (Optional) Indicates whether the endInUnits property must be present. If true, endInUnits must be specified or a bad request code is returned. Applies to Live Streaming only. Allowed values: false, true.

  • liveBackoffInUnits - (Optional) The relative to end right edge. Applies to Live Streaming only. This value defines the latest live position that a client can seek to. Using this property, you can delay live playback position and create a server-side buffer for players. The unit is defined by unitTimescaleInMiliseconds. The maximum live back off duration is 300 seconds. For example, a value of 20 means that the latest available content is 20 seconds delayed from the real live edge.

  • presentationWindowInUnits - (Optional) The relative to end sliding window. Applies to Live Streaming only. Use presentationWindowInUnits to apply a sliding window of fragments to include in a playlist. The unit is defined by unitTimescaleInMiliseconds. For example, set presentationWindowInUnits to 120 to apply a two-minute sliding window. Media within 2 minutes of the live edge will be included in the playlist. If a fragment straddles the boundary, the entire fragment will be included in the playlist. The minimum presentation window duration is 60 seconds.

  • startInUnits - (Optional) The absolute start time boundary. Applies to Video on Demand (VoD) or Live Streaming. This is a long value that represents an absolute start point of the stream. The value gets rounded to the closest next GOP start. The unit is defined by unitTimescaleInMiliseconds, so a startInUnits of 15 would be for 15 seconds. Use startInUnits and endInUnits to trim the fragments that will be in the playlist (manifest). For example, startInUnits set to 20 and endInUnits set to 60 using unitTimescaleInMiliseconds in 1000 will generate a playlist that contains fragments from between 20 seconds and 60 seconds of the VoD presentation. If a fragment straddles the boundary, the entire fragment will be included in the manifest.

  • unitTimescaleInMiliseconds - (Optional) Specified as the number of miliseconds in one unit timescale. For example, if you want to set a startInUnits at 30 seconds, you would use a value of 30 when using the unitTimescaleInMiliseconds in 1000. Or if you want to set startInUnits in 30 miliseconds, you would use a value of 30 when using the unitTimescaleInMiliseconds in 1. Applies timescale to startInUnits, startTimescale and presentationWindowInTimescale and liveBackoffInTimescale.


A trackSelection block supports the following:

  • condition - (Required) One or more condition blocks as defined above.


A condition block supports the following:

  • operation - (Optional) The condition operation to test a track property against. Supported values are equal and notEqual.

  • property - (Optional) The track property to compare. Supported values are bitrate, fourCc, language, name and type. Check documentation for more details.

  • value - (Optional) The track property value to match or not match.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Asset Filter.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Asset Filter.
  • read - (Defaults to 5 minutes) Used when retrieving the Asset Filter.
  • update - (Defaults to 30 minutes) Used when updating the Asset Filter.
  • delete - (Defaults to 30 minutes) Used when deleting the Asset Filter.

Import

Asset Filters can be imported using the resourceId, e.g.

terraform import azurerm_media_asset_filter.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Media/mediaServices/account1/assets/asset1/assetFilters/filter1