Exemplo n.º 1
0
def create_asset_filter(client, account_name, resource_group_name, asset_name, filter_name,
                        start_timestamp=None, end_timestamp=None, presentation_window_duration=None,
                        live_backoff_duration=None, timescale=None, force_end_timestamp=False,
                        bitrate=None, first_quality=None,
                        tracks=None):

    presentation_time_range = None

    if first_quality or bitrate:
        first_quality = FirstQuality(bitrate=first_quality or bitrate)

    if any([start_timestamp, end_timestamp, presentation_window_duration,
            live_backoff_duration, timescale]):
        presentation_time_range = PresentationTimeRange(
            start_timestamp=start_timestamp,
            end_timestamp=end_timestamp,
            presentation_window_duration=presentation_window_duration,
            live_backoff_duration=live_backoff_duration,
            timescale=timescale,
            force_end_timestamp=force_end_timestamp
        )

    asset_filter = AssetFilter(
        presentation_time_range=presentation_time_range,
        first_quality=first_quality,
        tracks=_parse_filter_tracks_json(tracks)
    )

    return client.create_or_update(resource_group_name, account_name, asset_name, filter_name, asset_filter)
Exemplo n.º 2
0
def update_asset_filter(instance, start_timestamp=None, end_timestamp=None, presentation_window_duration=None,
                        live_backoff_duration=None, timescale=None, bitrate=None, first_quality=None,
                        tracks=None, force_end_timestamp=None):

    if not instance:
        raise CLIError('The asset filter resource was not found.')

    if first_quality or bitrate:
        instance.first_quality = FirstQuality(bitrate=first_quality or bitrate)

    if any([start_timestamp, end_timestamp, presentation_window_duration,
            live_backoff_duration, timescale, force_end_timestamp is not None]):

        if instance.presentation_time_range is None:
            if not all([start_timestamp, end_timestamp, presentation_window_duration,
                        live_backoff_duration, timescale, force_end_timestamp is not None]):
                raise CLIError('All parameters related to PresentationTimeRange must be set to create it.')

            instance.presentation_time_range = PresentationTimeRange(
                start_timestamp=start_timestamp,
                end_timestamp=end_timestamp,
                presentation_window_duration=presentation_window_duration,
                live_backoff_duration=live_backoff_duration,
                timescale=timescale,
                force_end_timestamp=force_end_timestamp
            )

        else:
            if start_timestamp is not None:
                instance.presentation_time_range.start_timestamp = start_timestamp

            if end_timestamp is not None:
                instance.presentation_time_range.end_timestamp = end_timestamp

            if presentation_window_duration is not None:
                instance.presentation_time_range.presentation_window_duration = presentation_window_duration

            if live_backoff_duration is not None:
                instance.presentation_time_range.live_backoff_duration = live_backoff_duration

            if force_end_timestamp is not None:
                instance.presentation_time_range.force_end_timestamp = force_end_timestamp

            if timescale is not None:
                instance.presentation_time_range.timescale = timescale

    if tracks is not None:
        instance.tracks = _parse_filter_tracks_json(tracks)

    return instance
Exemplo n.º 3
0
 asset_filter_name = 'filter1'
 
 # Create the asset filter
 asset_filter = client.asset_filters.create_or_update(
   resource_group_name=resource_group,
   account_name=account_name,
   asset_name=out_asset_name,
   filter_name=asset_filter_name,
   parameters=AssetFilter(
     # In this sample, we are going to filter the manifest by the time range of the presentation using the default timescale.
     # You can adjust these settings for your own needs. Not that you can also control output tracks, and quality levels with a filter.
     tracks=[],
     # start_timestamp = 100000000 and end_timestamp = 300000000 using the default timescale will generate
     # a play-list that contains fragments from between 10 seconds and 30 seconds of the VoD presentation.
     # If a fragment straddles the boundary, the entire fragment will be included in the manifest.
     presentation_time_range=PresentationTimeRange(start_timestamp=100000000, end_timestamp=300000000)
   )
 )
 
 if asset_filter:
   print(f"The asset filter ({asset_filter_name}) was successfully created.")
   print()
 else:
   raise ValueError("There was an issue creating the asset filter.")
 
 if locator.name:
   hls_format = "format=m3u8-cmaf"
   dash_format = "format=mpd-time-cmaf"
   
   # Get the default streaming endpoint on the account
   streaming_endpoint = client.streaming_endpoints.get(