CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-google-cloud-video-live-stream

Google Cloud Video Live Stream API client library that transcodes mezzanine live signals into direct-to-consumer streaming formats, including Dynamic Adaptive Streaming over HTTP (DASH/MPEG-DASH), and HTTP Live Streaming (HLS), for multiple device platforms.

Pending
Overview
Eval results
Files

asset-dvr-management.mddocs/

Asset and DVR Management

Management of media assets and Digital Video Recording (DVR) sessions for creating recordings, clips, and time-shifted viewing experiences from live streams.

Asset Management Capabilities

Creating Assets

Creates a new media asset that can be used for slate content, ad insertion, or other overlay purposes in live streams.

def create_asset(
    self,
    request: Union[CreateAssetRequest, dict] = None,
    *,
    parent: str = None,
    asset: Asset = None,
    asset_id: str = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> operation.Operation:
    """
    Creates an asset with the provided unique ID in the specified region.

    Args:
        request: The request object containing parent, asset_id, asset, and request_id
        parent: Required. The parent location path (projects/{project}/locations/{location})
        asset: Required. The asset resource to create
        asset_id: Required. The ID to use for the asset (must be unique within parent)
        retry: Retry configuration for the request
        timeout: Request timeout in seconds
        metadata: Additional metadata for the request

    Returns:
        google.api_core.operation.Operation: Long-running operation
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Listing Assets

Retrieves a list of media assets with pagination and filtering capabilities.

def list_assets(
    self,
    request: Union[ListAssetsRequest, dict] = None,
    *,
    parent: str = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> pagers.ListAssetsPager:
    """
    Returns a list of all assets in the specified region.

    Args:
        request: The request object containing parent, page_size, page_token, filter, order_by
        parent: Required. The parent path (projects/{project}/locations/{location})
        retry: Retry configuration for the request
        timeout: Request timeout in seconds
        metadata: Additional metadata for the request

    Returns:
        pagers.ListAssetsPager: Pager for iterating over asset results
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Getting Asset Details

Retrieves detailed information about a specific asset including its content, state, and metadata.

def get_asset(
    self,
    request: Union[GetAssetRequest, dict] = None,
    *,
    name: str = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> Asset:
    """
    Returns the specified asset.

    Args:
        request: The request object containing name
        name: Required. The asset name (projects/{project}/locations/{location}/assets/{asset})
        retry: Retry configuration for the request
        timeout: Request timeout in seconds
        metadata: Additional metadata for the request

    Returns:
        Asset: The asset resource
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Deleting Assets

Permanently removes a media asset and all associated data.

def delete_asset(
    self,
    request: Union[DeleteAssetRequest, dict] = None,
    *,
    name: str = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> operation.Operation:
    """
    Deletes the specified asset.

    Args:
        request: The request object containing name and request_id
        name: Required. The asset name (projects/{project}/locations/{location}/assets/{asset})
        retry: Retry configuration for the request
        timeout: Request timeout in seconds
        metadata: Additional metadata for the request

    Returns:
        google.api_core.operation.Operation: Long-running operation
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

DVR Session Management Capabilities

Creating DVR Sessions

Creates a new DVR session for recording live streams with configurable retention and time window settings.

def create_dvr_session(
    self,
    request: Union[CreateDvrSessionRequest, dict] = None,
    *,
    parent: str = None,
    dvr_session: DvrSession = None,
    dvr_session_id: str = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> DvrSession:
    """
    Creates a DVR session with the provided unique ID in the specified channel.

    Args:
        request: The request object containing parent, dvr_session_id, dvr_session, and request_id
        parent: Required. The parent channel (projects/{project}/locations/{location}/channels/{channel})
        dvr_session: Required. The DVR session resource to create
        dvr_session_id: Required. The ID to use for the DVR session
        retry: Retry configuration for the request
        timeout: Request timeout in seconds
        metadata: Additional metadata for the request

    Returns:
        DvrSession: The created DVR session resource
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Listing DVR Sessions

Retrieves a list of DVR sessions with pagination and filtering capabilities.

def list_dvr_sessions(
    self,
    request: Union[ListDvrSessionsRequest, dict] = None,
    *,
    parent: str = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> pagers.ListDvrSessionsPager:
    """
    Returns a list of all DVR sessions in the specified channel.

    Args:
        request: The request object containing parent, page_size, page_token, filter, order_by
        parent: Required. The parent channel (projects/{project}/locations/{location}/channels/{channel})
        retry: Retry configuration for the request
        timeout: Request timeout in seconds
        metadata: Additional metadata for the request

    Returns:
        pagers.ListDvrSessionsPager: Pager for iterating over DVR session results
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Getting DVR Session Details

Retrieves detailed information about a specific DVR session including its recording state and available time ranges.

def get_dvr_session(
    self,
    request: Union[GetDvrSessionRequest, dict] = None,
    *,
    name: str = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> DvrSession:
    """
    Returns the specified DVR session.

    Args:
        request: The request object containing name
        name: Required. The DVR session name (projects/{project}/locations/{location}/channels/{channel}/dvrSessions/{dvrSession})
        retry: Retry configuration for the request
        timeout: Request timeout in seconds
        metadata: Additional metadata for the request

    Returns:
        DvrSession: The DVR session resource
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Updating DVR Sessions

Updates DVR session configuration including retention settings and time windows.

def update_dvr_session(
    self,
    request: Union[UpdateDvrSessionRequest, dict] = None,
    *,
    dvr_session: DvrSession = None,
    update_mask: field_mask_pb2.FieldMask = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> DvrSession:
    """
    Updates the specified DVR session.

    Args:
        request: The request object containing update_mask, dvr_session, and request_id
        dvr_session: Required. The DVR session resource with updated fields
        update_mask: Required. Field mask specifying which fields to update
        retry: Retry configuration for the request
        timeout: Request timeout in seconds
        metadata: Additional metadata for the request

    Returns:
        DvrSession: The updated DVR session resource
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Deleting DVR Sessions

Permanently removes a DVR session and all associated recorded content.

def delete_dvr_session(
    self,
    request: Union[DeleteDvrSessionRequest, dict] = None,
    *,
    name: str = None,
    retry: OptionalRetry = gapic_v1.method.DEFAULT,
    timeout: Union[float, object] = gapic_v1.method.DEFAULT,
    metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> None:
    """
    Deletes the specified DVR session.

    Args:
        request: The request object containing name and request_id
        name: Required. The DVR session name (projects/{project}/locations/{location}/channels/{channel}/dvrSessions/{dvrSession})
        retry: Retry configuration for the request
        timeout: Request timeout in seconds
        metadata: Additional metadata for the request

    Returns:
        None
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Asset and DVR Types

Asset Resource

class Asset:
    """
    Asset resource represents media content that can be used in live streams.
    
    Attributes:
        name (str): Asset resource name
        create_time (google.protobuf.timestamp_pb2.Timestamp): Creation timestamp
        update_time (google.protobuf.timestamp_pb2.Timestamp): Last update timestamp
        labels (MutableMapping[str, str]): User-defined labels
        video (VideoAsset): Video asset configuration
        crc32c (str): CRC32C checksum of the asset
        state (State): Current asset state
        error (google.rpc.status_pb2.Status): Any processing errors
    """
    
    class State(proto.Enum):
        """Asset state enumeration."""
        STATE_UNSPECIFIED = 0
        CREATING = 1
        ACTIVE = 2
        DELETING = 3
        ERROR = 4
    
    class VideoAsset:
        """Video asset configuration."""
        uri (str): Cloud Storage URI of the video file

DVR Session Resource

class DvrSession:
    """
    DVR session resource for recording live streams.
    
    Attributes:
        name (str): DVR session resource name
        create_time (google.protobuf.timestamp_pb2.Timestamp): Creation timestamp
        update_time (google.protobuf.timestamp_pb2.Timestamp): Last update timestamp
        labels (MutableMapping[str, str]): User-defined labels
        start_time (google.protobuf.timestamp_pb2.Timestamp): Recording start time
        end_time (google.protobuf.timestamp_pb2.Timestamp): Recording end time
        retention_config (RetentionConfig): Data retention configuration
        dvr_end_time (google.protobuf.timestamp_pb2.Timestamp): Actual DVR end time
        state (State): Current DVR session state
        error (google.rpc.status_pb2.Status): Any recording errors
    """
    
    class State(proto.Enum):
        """DVR session state enumeration."""
        STATE_UNSPECIFIED = 0
        CREATING = 1
        ACTIVE = 2
        STOPPED = 3
        ERROR = 4

Retention Configuration

class RetentionConfig:
    """
    Data retention configuration for DVR sessions.
    
    Attributes:
        retention_window_duration (google.protobuf.duration_pb2.Duration): How long to retain data
    """

Usage Examples

Creating Video Asset

from google.cloud.video import live_stream_v1

client = live_stream_v1.LivestreamServiceClient()

# Create asset from Cloud Storage video file
asset = live_stream_v1.Asset(
    video=live_stream_v1.Asset.VideoAsset(
        uri="gs://my-bucket/videos/slate.mp4"
    )
)

request = live_stream_v1.CreateAssetRequest(
    parent="projects/my-project/locations/us-central1",
    asset_id="slate-video",
    asset=asset
)

operation = client.create_asset(request=request)
asset_result = operation.result()
print(f"Created asset: {asset_result.name}")

Creating DVR Session

from google.protobuf import timestamp_pb2, duration_pb2
import datetime

# Create DVR session for 2-hour window
start_time = datetime.datetime.now()
end_time = start_time + datetime.timedelta(hours=2)

start_timestamp = timestamp_pb2.Timestamp()
end_timestamp = timestamp_pb2.Timestamp()
start_timestamp.FromDatetime(start_time)
end_timestamp.FromDatetime(end_time)

# Retain data for 24 hours
retention_duration = duration_pb2.Duration(seconds=24*60*60)

dvr_session = live_stream_v1.DvrSession(
    start_time=start_timestamp,
    end_time=end_timestamp,
    retention_config=live_stream_v1.RetentionConfig(
        retention_window_duration=retention_duration
    )
)

request = live_stream_v1.CreateDvrSessionRequest(
    parent="projects/my-project/locations/us-central1/channels/my-channel",
    dvr_session_id="recording-session-1",
    dvr_session=dvr_session
)

dvr_result = client.create_dvr_session(request=request)
print(f"Created DVR session: {dvr_result.name}")

Managing Asset Lifecycle

# List all assets
list_request = live_stream_v1.ListAssetsRequest(
    parent="projects/my-project/locations/us-central1"
)

for asset in client.list_assets(request=list_request):
    print(f"Asset: {asset.name}, State: {asset.state}")
    
    # Check if asset is ready
    if asset.state == live_stream_v1.Asset.State.ACTIVE:
        print(f"Asset {asset.name} is ready for use")
    elif asset.state == live_stream_v1.Asset.State.ERROR:
        print(f"Asset {asset.name} failed: {asset.error.message}")

# Get specific asset details
get_request = live_stream_v1.GetAssetRequest(
    name="projects/my-project/locations/us-central1/assets/my-asset"
)
asset = client.get_asset(request=get_request)
print(f"Asset URI: {asset.video.uri}")
print(f"Asset checksum: {asset.crc32c}")

Managing DVR Sessions

from google.protobuf import field_mask_pb2

# Update DVR session retention
updated_dvr = live_stream_v1.DvrSession(
    name="projects/my-project/locations/us-central1/channels/my-channel/dvrSessions/my-session",
    retention_config=live_stream_v1.RetentionConfig(
        retention_window_duration=duration_pb2.Duration(seconds=48*60*60)  # 48 hours
    )
)

update_mask = field_mask_pb2.FieldMask(
    paths=["retention_config.retention_window_duration"]
)

update_request = live_stream_v1.UpdateDvrSessionRequest(
    dvr_session=updated_dvr,
    update_mask=update_mask
)

updated_session = client.update_dvr_session(request=update_request)

# Monitor DVR session state
get_request = live_stream_v1.GetDvrSessionRequest(
    name="projects/my-project/locations/us-central1/channels/my-channel/dvrSessions/my-session"
)

session = client.get_dvr_session(request=get_request)
print(f"DVR session state: {session.state}")
print(f"Recording from {session.start_time} to {session.end_time}")

Install with Tessl CLI

npx tessl i tessl/pypi-google-cloud-video-live-stream

docs

asset-dvr-management.md

channel-management.md

clip-management.md

event-management.md

index.md

input-management.md

pool-management.md

tile.json