将 Amazon EventBridge 与 IVS 实时直播功能结合使用 - Amazon IVS

将 Amazon EventBridge 与 IVS 实时直播功能结合使用

您可以使用 Amazon EventBridge 来监控您的 Amazon Interactive Video Service (IVS) 流。

Amazon IVS 将有关流状态的更改事件发送到 Amazon EventBridge。传递的所有事件都有效。但是,事件将尽最大努力发出,这意味着并不能保证:

  • 传送事件:会发生指定的事件(例如,参与者发布的事件),但 Amazon IVS 可能不会向 EventBridge 发送相应的事件。Amazon IVS 尝试在放弃之前传递几个小时的事件。

  • 事件将在指定的时间范围内传递 – 您可能会收到几个小时之前的事件。

  • 按顺序传送事件:事件可能无序,尤其是在短时间内相互发送的情况下。例如,您可以在参与者发布之前看到参与者未发布的事件。

尽管事件丢失、延迟或无序的情况很少,但如果您编写了取决于通知事件的顺序或存在的关键业务程序,则应处理这些可能性。

您可以为以下任何事件创建 EventBridge 规则。

事件类型 活动 发送时间:
IVS 合成状态更改 目标故障 尝试输出到目标失败。例如,由于没有流密钥或正在进行其他广播,向某个频道广播失败。
IVS 合成状态更改 目的地开始 输出到目标成功启动。
IVS 合成状态更改 目标结束 输出到目标已完成。
IVS 合成状态更改 目标重新连接 向目标的输出中断,正在尝试重新连接。
IVS 合成状态更改 会话开始 合成会话已创建。合成进程管道初始化成功时触发此事件。此时,合成管道已成功订阅舞台,正在接收媒体并能够合成视频。
IVS 合成状态更改 会话结束 合成会话已完成。
IVS 合成状态更改 会话失败 由于舞台资源不可用或任何其他内部错误,合成管道无法初始化。
IVS 参与者录制状态更改 开始录制 发布者已连接到暂存区并正在录制到 S3。
IVS 参与者录制状态更改 结束录制 发布者已断开与暂存区的连接,所有剩余文件均已写入 S3。
IVS 参与者录制状态更改 录制启动失败 发布者已连接到暂存区,但由于错误(例如,S3 存储桶不存在或不在正确的区域)而无法开始录制。未录制此发布者的实时直播
IVS 参与者录制状态更改 录制结束失败 由于录制过程中遇到错误(例如,如果尝试写入媒体播放列表连续失败),录制以失败结束。某些对象可能仍会写入已配置的存储位置。
IVS 舞台更新 参与者已发布 参与者开始发布到舞台。
IVS 舞台更新 参与者已取消发布 参与者已停止发布到舞台。
IVS 舞台更新 参与者发布错误 参与者尝试发布到暂存区失败。

为 Amazon IVS 创建 Amazon EventBridge 规则

您可以创建针对 Amazon IVS 发出的事件进行触发的规则。请按照 Amazon EventBridge User Guide 中的 Create a rule in Amazon EventBridge 步骤操作。选择服务时,选择 Interactive Video Service(IVS)

示例:合成状态更改

目标失败:尝试输出到目标失败时发送此事件。例如,由于没有流密钥或正在进行其他广播,向某个频道广播失败。

{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Composition State Change", "source": "aws.ivs", "account": "aws_account_id", "time": "2017-06-12T10:23:43Z", "region": "us-east-1", "resources": [ "arn:aws:ivs:us-east-1:aws_account_id:composition/123456789012" ], "detail": { "event_name": "Destination Failure", "stage_arn": "<stage-arn>", "id": "<Destination-id>", "reason": "eg. stream key invalid" } }

目标启动:成功启动向目标的输出时发送此事件。

{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Composition State Change", "source": "aws.ivs", "account": "aws_account_id", "time": "2017-06-12T10:23:43Z", "region": "us-east-1", "resources": [ "arn:aws:ivs:us-east-1:aws_account_id:composition/123456789012" ], "detail": { "event_name": "Destination Start", "stage_arn": "<stage-arn>", "id": "<destination-id>", } }

目标结束:向目标输出完成发送此事件。

{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Composition State Change", "source": "aws.ivs", "account": "aws_account_id", "time": "2017-06-12T10:23:43Z", "region": "us-east-1", "resources": [ "arn:aws:ivs:us-east-1:aws_account_id:composition/123456789012" ], "detail": { "event_name": "Destination End", "stage_arn": "<stage-arn>", "id": "<Destination-id>", } }

目标重新连接:向目标的输出中断并且正在尝试重新连接时,发送此事件。

{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Composition State Change", "source": "aws.ivs", "account": "aws_account_id", "time": "2017-06-12T10:23:43Z", "region": "us-east-1", "resources": [ "arn:aws:ivs:us-east-1:aws_account_id:composition/123456789012" ], "detail": { "event_name": "Destination Reconnecting", "stage_arn": "<stage-arn>", "id": "<Destination-id>", } }

会话开始:创建合成会话时发送此事件。合成进程管道初始化成功时触发此事件。此时,合成管道已成功订阅舞台,正在接收媒体并能够合成视频。

{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Composition State Change", "source": "aws.ivs", "account": "aws_account_id", "time": "2017-06-12T10:23:43Z", "region": "us-east-1", "resources": [ "arn:aws:ivs:us-east-1:aws_account_id:composition/123456789012" ], "detail": { "event_name": "Session Start", "stage_arn": "<stage-arn>" } }

会话结束:合成会话完成并且删除了所有资源时,发送此事件。

{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Composition State Change", "source": "aws.ivs", "account": "aws_account_id", "time": "2017-06-12T10:23:43Z", "region": "us-east-1", "resources": [ "arn:aws:ivs:us-east-1:aws_account_id:composition/123456789012" ], "detail": { "event_name": "Session End", "stage_arn": "<stage-arn>" } }

会话失败:由于舞台资源不可用、舞台中没有参与者或任何其他内部错误而导致合成管道无法初始化时,发送此事件。

{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Composition State Change", "source": "aws.ivs", "account": "aws_account_id", "time": "2017-06-12T10:23:43Z", "region": "us-east-1", "resources": [ "arn:aws:ivs:us-east-1:aws_account_id:composition/123456789012" ], "detail": { "event_name": "Session Failure", "stage_arn": "<stage-arn>", "reason": "eg. no participants in the stage" } }

示例:单个参与者录制状态更改

录制开始:当发布者已连接到暂存区并正在录制到 S3 时,将发送此事件。

{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Participant Recording State Change", "source": "aws.ivs", "account": "123456789012", "time": "2024-03-13T22:09:58Z", "region": "us-east-1", "resources": ["arn:aws:ivs:us-west-2:aws_account_id:stage/AbCdef1G2hij"], "detail": { "session_id": "st-ZyXwvu1T2s", "event_name": "Recording Start", "participant_id": "xYz1c2d3e4f", "recording_s3_bucket_name": "bucket-name", "recording_s3_key_prefix": "<stage_id>/<session_id>/<participant_id>/2024-01-01T12-00-55Z" } }

录制结束:当发布者已断开与暂存区的连接且所有剩余文件均已写入 S3 时,将发送此事件。

{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Participant Recording State Change", "source": "aws.ivs", "account": "123456789012", "time": "2024-03-13T22:19:04Z", "region": "us-east-1", "resources": ["arn:aws:ivs:us-west-2:aws_account_id:stage/AbCdef1G2hij"], "detail": { "session_id": "st-ZyXwvu1T2s", "event_name": "Recording End", "participant_id": "xYz1c2d3e4f", "recording_s3_bucket_name": "bucket-name", "recording_s3_key_prefix": "<stage_id>/<session_id>/<participant_id>/2024-01-01T12-00-55Z" "recording_duration_ms": 547327 } }

录制开始失败:当发布者连接到暂存区,但由于错误(例如,S3 存储桶不存在或不在正确的区域)而无法开始录制时,将发送此事件。发布者的实时直播未录制。

{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Participant Recording State Change", "source": "aws.ivs", "account": "123456789012", "time": "2024-03-13T22:09:58Z", "region": "us-east-1", "resources": ["arn:aws:ivs:us-west-2:aws_account_id:stage/AbCdef1G2hij"], "detail": { "session_id": "st-ZyXwvu1T2s", "event_name": "Recording Start Failure", "participant_id": "xYz1c2d3e4f", "recording_s3_bucket_name": "bucket-name", "recording_s3_key_prefix": "<stage_id>/<session_id>/<participant_id>/2024-01-01T12-00-55Z" } }

录制结束失败:由于录制过程中遇到错误(例如,如果尝试写入主播放列表失败),录制以失败结束时,将发送此事件。某些对象可能仍会写入已配置的存储位置。

{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Participant Recording State Change", "source": "aws.ivs", "account": "123456789012", "time": "2024-03-13T22:19:04Z", "region": "us-east-1", "resources": ["arn:aws:ivs:us-west-2:aws_account_id:stage/AbCdef1G2hij"], "detail": { "session_id": "st-ZyXwvu1T2s", "event_name": "Recording End Failure", "participant_id": "xYz1c2d3e4f", "recording_s3_bucket_name": "bucket-name", "recording_s3_key_prefix": "<stage_id>/<session_id>/<participant_id>/2024-01-01T12-00-55Z" "recording_duration_ms": 547327 } }

示例:舞台更新

舞台更新事件包括事件名称(用于对事件进行分类)和有关该事件的元数据。元数据包括触发事件的参与者 ID、相关舞台和会话 ID 以及用户 ID。

参与者已发布:在参与者开始发布到舞台时发送该事件。

{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Stage Update", "source": "aws.ivs", "account": "123456789012", "time": "2020-06-23T20:12:36Z", "region": "us-west-2", "resources": [ "arn:aws:ivs:us-west-2:123456789012:stage/AbCdef1G2hij" ], "detail": { "session_id": "st-ZyXwvu1T2s", "event_name": "Participant Published", "user_id": "Your User Id", "participant_id": "xYz1c2d3e4f" } }

参与者已取消发布:在参与者已停止发布到舞台时发送该事件。

{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Stage Update", "source": "aws.ivs", "account": "123456789012", "time": "2020-06-23T20:12:36Z", "region": "us-west-2", "resources": [ "arn:aws:ivs:us-west-2:123456789012:stage/AbCdef1G2hij" ], "detail": { "session_id": "st-ZyXwvu1T2s", "event_name": "Participant Unpublished", "user_id": "Your User Id", "participant_id": "xYz1c2d3e4f" } }

参与者发布错误:当参与者尝试发布到暂存区失败时,将发送此事件。

{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Stage Update", "source": "aws.ivs", "account": "123456789012", "time": "2020-06-23T20:12:36Z", "region": "us-west-2", "resources": [ "arn:aws:ivs:us-west-2:123456789012:stage/AbCdef1G2hij" ], "detail": { "session_id": "st-ZyXwvu1T2s", "event_name": "Participant Publish Error", "event_time": "2024-08-13T14:38:17.089061676Z", "user_id": "Your User Id", "participant_id": "xYz1c2d3e4f", "error_code": "BITRATE_EXCEEDED" } }