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

channel-management.mddocs/

Channel Management

Complete channel lifecycle management for live streaming operations including creation, configuration, starting/stopping, and deletion of live streaming channels with support for multiple output formats and quality levels.

Capabilities

Creating Channels

Creates a new live streaming channel with input attachments, output configurations, and optional features like encryption, timecode, and sprite sheets.

def create_channel(
    self,
    request: Union[CreateChannelRequest, dict] = None,
    *,
    parent: str = None,
    channel: Channel = None,
    channel_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 a channel with the provided unique ID in the specified region.

    Args:
        request: The request object containing parent, channel_id, channel, and request_id
        parent: Required. The parent location path (projects/{project}/locations/{location})
        channel: Required. The channel resource to create
        channel_id: Required. The ID to use for the channel (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 Channels

Retrieves a list of channels with optional filtering, pagination, and sorting capabilities.

def list_channels(
    self,
    request: Union[ListChannelsRequest, 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.ListChannelsPager:
    """
    Returns a list of all channels 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.ListChannelsPager: Pager for iterating over channel results
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Getting Channel Details

Retrieves detailed information about a specific channel including its current state, configuration, and streaming status.

def get_channel(
    self,
    request: Union[GetChannelRequest, 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]]] = ()
) -> Channel:
    """
    Returns the specified channel.

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

    Returns:
        Channel: The channel resource
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Updating Channels

Updates channel configuration including input attachments, output settings, and other properties while preserving channel state.

def update_channel(
    self,
    request: Union[UpdateChannelRequest, dict] = None,
    *,
    channel: Channel = 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]]] = ()
) -> operation.Operation:
    """
    Updates the specified channel.

    Args:
        request: The request object containing update_mask, channel, and request_id
        channel: Required. The channel 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:
        google.api_core.operation.Operation: Long-running operation
        
    Raises:
        google.api_core.exceptions.GoogleAPICallError: If the request fails
    """

Starting Channels

Starts a live streaming channel, initiating the transcoding pipeline and making the channel ready to receive input streams.

def start_channel(
    self,
    request: Union[StartChannelRequest, 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:
    """
    Starts the specified channel.

    Args:
        request: The request object containing name and request_id
        name: Required. The channel name (projects/{project}/locations/{location}/channels/{channel})
        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
    """

Stopping Channels

Stops an active streaming channel, halting the transcoding pipeline and input processing while preserving channel configuration.

def stop_channel(
    self,
    request: Union[StopChannelRequest, 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:
    """
    Stops the specified channel.

    Args:
        request: The request object containing name and request_id
        name: Required. The channel name (projects/{project}/locations/{location}/channels/{channel})
        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
    """

Deleting Channels

Permanently removes a channel and all associated resources including output manifests and stream data.

def delete_channel(
    self,
    request: Union[DeleteChannelRequest, 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 channel.

    Args:
        request: The request object containing name and request_id
        name: Required. The channel name (projects/{project}/locations/{location}/channels/{channel})
        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
    """

Channel Configuration Types

Channel Resource

class Channel:
    """
    Channel resource represents a live streaming channel configuration.
    
    Attributes:
        name (str): Channel 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
        input_attachments (MutableSequence[InputAttachment]): Attached input sources
        active_input (str): Currently active input key
        output (ElementaryStream): Primary output stream configuration
        elementary_streams (MutableSequence[ElementaryStream]): All elementary streams
        mux_streams (MutableSequence[MuxStream]): Multiplexed stream configurations
        manifests (MutableSequence[Manifest]): Output manifest configurations
        sprite_sheets (MutableSequence[SpriteSheet]): Sprite sheet configurations
        streaming_state (StreamingState): Current streaming state
        streaming_error (google.rpc.status_pb2.Status): Any streaming errors
        log_config (LogConfig): Logging configuration
        timecode_config (TimecodeConfig): Timecode handling configuration
        encryptions (MutableSequence[Encryption]): Encryption configurations
    """
    
    class StreamingState(proto.Enum):
        """Channel streaming state enumeration."""
        STREAMING_STATE_UNSPECIFIED = 0
        STREAMING = 1
        AWAITING_INPUT = 2
        STREAMING_ERROR = 3
        STREAMING_NO_INPUT = 4
        STOPPED = 5
        STARTING = 6
        STOPPING = 7

Input Attachment

class InputAttachment:
    """
    Input attachment links an input to a channel.
    
    Attributes:
        key (str): Unique identifier for this attachment within the channel
        input (str): Input resource name to attach
        automatic_failover (AutomaticFailover): Failover configuration
    """
    
    class AutomaticFailover:
        """Automatic failover configuration for input attachments."""
        input_keys (MutableSequence[str]): Ordered list of input keys for failover

Usage Examples

Basic Channel Creation

from google.cloud.video import live_stream_v1

client = live_stream_v1.LivestreamServiceClient()

# Create channel with single input attachment
channel = live_stream_v1.Channel(
    input_attachments=[
        live_stream_v1.InputAttachment(
            key="input1",
            input="projects/my-project/locations/us-central1/inputs/my-input"
        )
    ],
    output=live_stream_v1.outputs.ElementaryStream(
        video_stream=live_stream_v1.outputs.VideoStream(
            h264=live_stream_v1.outputs.VideoStream.H264CodecSettings(
                bitrate_bps=2000000,
                frame_rate=30,
                height_pixels=720,
                width_pixels=1280
            )
        ),
        audio_stream=live_stream_v1.outputs.AudioStream(
            codec="aac",
            bitrate_bps=128000,
            channel_count=2,
            channel_layout=["fl", "fr"],
            sample_rate_hertz=48000
        )
    )
)

request = live_stream_v1.CreateChannelRequest(
    parent="projects/my-project/locations/us-central1",
    channel_id="my-live-channel",
    channel=channel
)

operation = client.create_channel(request=request)
channel_resource = operation.result()
print(f"Created channel: {channel_resource.name}")

Channel with Multiple Outputs

# Create channel with HLS and DASH manifests
channel = live_stream_v1.Channel(
    input_attachments=[
        live_stream_v1.InputAttachment(
            key="primary",
            input="projects/my-project/locations/us-central1/inputs/input-1"
        )
    ],
    elementary_streams=[
        live_stream_v1.outputs.ElementaryStream(
            key="video-720p",
            video_stream=live_stream_v1.outputs.VideoStream(
                h264=live_stream_v1.outputs.VideoStream.H264CodecSettings(
                    bitrate_bps=2000000,
                    frame_rate=30,
                    height_pixels=720,
                    width_pixels=1280
                )
            )
        ),
        live_stream_v1.outputs.ElementaryStream(
            key="audio-128k",
            audio_stream=live_stream_v1.outputs.AudioStream(
                codec="aac",
                bitrate_bps=128000,
                channel_count=2,
                sample_rate_hertz=48000
            )
        )
    ],
    mux_streams=[
        live_stream_v1.outputs.MuxStream(
            key="mux-720p",
            elementary_streams=["video-720p", "audio-128k"],
            segment_settings=live_stream_v1.outputs.SegmentSettings(
                segment_duration=duration_pb2.Duration(seconds=4)
            )
        )
    ],
    manifests=[
        live_stream_v1.outputs.Manifest(
            file_name="manifest.m3u8",
            type_=live_stream_v1.outputs.Manifest.ManifestType.HLS,
            mux_streams=["mux-720p"]
        ),
        live_stream_v1.outputs.Manifest(
            file_name="manifest.mpd",
            type_=live_stream_v1.outputs.Manifest.ManifestType.DASH,
            mux_streams=["mux-720p"]
        )
    ]
)

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