将 Amazon EventBridge 与 IVS 低延迟直播功能结合使用
您可以使用 Amazon EventBridge 来监控您的 Amazon Interactive Video Service (IVS) 流。
Amazon IVS 将有关流状态的更改事件发送到 Amazon EventBridge。传递的所有事件都有效。但是,事件将尽最大努力发出,这意味着并不能保证:
-
传递事件 – 会发生指定的事件(例如,流启动),但 Amazon IVS 可能不会向 EventBridge 发送相应的更改事件。Amazon IVS 尝试在放弃之前传递几个小时的事件。
-
事件将在指定的时间范围内传递 – 您可能会收到几个小时之前的事件。
-
按顺序传送事件:事件可能无序,尤其是在短时间内相互发送的情况下。例如,您会在先看到向下流,再看到向上流。
尽管事件丢失、延迟或无序的情况很少,但如果您编写了取决于通知事件的顺序或存在的关键业务程序,则应处理这些可能性。
您可以为以下任何事件创建 EventBridge 规则。
事件类型 | 活动 | 发送时间: |
---|---|---|
IVS 流状态更改 | 已创建会话 | 已成功使用了通道流密钥并创建了流会话。将在启动流时触发此事件,然后再处理视频或将视频传送给查看器。此事件可以帮助您确定流是否已启动但未能上线;例如,由于配置错误或违反限制。 |
IVS 流状态更改 | 会话已结束 | 编码器断开连接,并且 Amazon IVS 不再接收视频。此事件可以帮助您确定编码器何时停止发送媒体。对于多轨道直播, 注意:当编码器断开连接时,“会话已结束”事件可能会发生在“流结束”事件之前。这是因为在“会话已结束”事件后的一小段时间内,Amazon IVS 仍在处理视频。 |
IVS 流状态更改 | 流启动 | 正在处理流,片段可供观众观看。此事件表示视频流正在处理中,查看器可以观看。此事件可以帮助您确定流是否成功上线。 |
IVS 流状态更改 | 流结束 | 流停止处理,不再为观众生成视频片段。此事件可以帮助您确定流何时结束,并且观众不能使用任何新的视频片段。(另请参阅“会话已结束”中的备注。) |
IVS 流状态更改 | 流失败 | 由于超出了处理容量,流尚未处理且不可用。 |
IVS 流状态更改 | 直播接管 | 现有直播已被接管。 |
IVS 流状态更改 | 直播接管失败 | 尝试接管现有直播被拒绝。code 字段提供了有关直播接管失败原因的更多详细信息。有几个值;请注意,IVS 控制台中提供了详细描述,但不通过 IVS API 或 EventBridge 提供:
|
IVS 流运行状况更改 | 饥饿开始 | 流没有从流播放器接收数据;流被称作处于“饥饿”状态。 |
IVS 流运行状况更改 | 饥饿结束 | 饥饿的流开始从流播放器接收数据,并且流再次运行正常。 |
IVS 限制违反 | 采集比特率 | 传入流的比特率超过 Amazon IVS 限制。 |
IVS 限制违反 | 采集分辨率 | 传入流的分辨率超过 Amazon IVS 限制。 |
IVS 限制违反 | 并发广播 | 同时流传输的通道总数超过 Amazon IVS 限制。 |
IVS 限制违反 | 并发观众 | 同时观看您通道的观众总数超过 Amazon IVS 限制。 |
IVS 录制状态更改 | 开始录制 | 开始处理流,并且已创建并验证录制前缀。将片段写入为通道配置的存储位置。 请注意,在实时流启动并发出录制开始事件后,需要一点时间将清单文件和视频段写入为通道配置的 S3 存储桶。我们建议仅在发送“录制结束”事件后回放或处理录制的流。 |
IVS 录制状态更改 | 结束录制 | 此通道的流结束并停止录制。 |
IVS 录制状态更改 | 录制启动失败 | 流启动,但由于错误而无法启动录制(例如,S3 存储桶不存在或不在正确的区域)。此实时流不会被录制。 |
IVS 录制状态更改 | 录制结束失败 | 由于录制过程中遇到错误,录制以失败结束(例如,如果尝试写入主播放列表失败)。某些对象可能仍会写入已配置的存储位置。 |
关于流 ID 的注释:stream_id
字段(在许多事件中)是每次通道上线时分配的唯一流标识符。对于给定通道,每个实时流都有一个新的 stream_id
。因此,每个通道 ARN 可以有许多相应的流 ID。流 ID 允许客户区分同一通道上的不同流会话。
关于某些事件延迟的注释:编码器配置设置,特别是 IDR/关键帧间隔,会影响流开启的时间和相关事件(流开启和录制开启)的延迟。较短的关键帧间隔会减少此延迟。请参阅 Amazon IVS 流式处理配置中的“减少延迟”,了解有关设置 IDR/Keyframe
的信息。
为 Amazon IVS 创建 Amazon EventBridge 规则
您可以创建针对 Amazon IVS 发出的事件进行触发的规则。请按照 Amazon EventBridge User Guide 中的 Create a rule in Amazon EventBridge 步骤操作。选择服务时,选择 Interactive Video Service(IVS)。
示例:流状态更改
会话已创建:成功使用通道直播密钥并创建了直播会话时发送此事件。
{ "version": "0", "id": "aa5b7a40-36cf-8dc4-5554-32d70e047215", "detail-type": "IVS Stream State Change", "source": "aws.ivs", "account": "535011710559", "time": "2024-09-09T16:17:26Z", "region": "us-east-1", "resources": [ "arn:aws:ivs:us-west-2:535011710559:channel/UCGaMPGLCbcE" ], "detail": { "event_name": "Session Created", "channel_name": "", "stream_id": "st-1AuTyMDASvHUTSb8p5PvbsO" } }
会话已结束:编码器断开连接且 IVS 不再接收视频时发送此事件。
{ "version": "0", "id": "6f2723f3-ee31-9e48-b030-ac865e261a8e", "detail-type": "IVS Stream State Change", "source": "aws.ivs", "account": "535011710559", "time": "2024-09-09T16:17:26Z", "region": "us-east-1", "resources": [ "arn:aws:ivs:us-west-2:535011710559:channel/UCGaMPGLCbcE" ], "detail": { "event_name": "Session Ended", "channel_name": "", "code": "MultitrackInputNotAllowed", "stream_id": "st-1AuTyMDASvHUTSb8p5PvbsO" } }
流开始:当流正在处理且片段可供观众观看时,将发送此事件。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Stream 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:channel/12345678-1a23-4567-a1bc-1a2b34567890" ], "detail": { "event_name": "Stream Start", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn" } }
流结束:当流停止处理并且不再为观众生成视频片段时,将发送此事件。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Stream 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:channel/12345678-1a23-4567-a1bc-1a2b34567890" ], "detail": { "event_name": "Stream End", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn" } }
流失败:当流未处理且由于超出了处理容量而不可用时,将发送此事件。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Stream 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:channel/12345678-1a23-4567-a1bc-1a2b34567890" ], "detail": { "event_name": "Stream Failure", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn", "reason": "Transcode capacity exceeded. Please try again." } }
直播接管:现有直播被接管时发送此事件。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Stream 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:channel/12345678-1a23-4567-a1bc-1a2b34567890" ], "detail": { "event_name": "Stream Takeover", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn" } }
直播接管失败:尝试接管现有直播被拒绝时发送此事件。这可能是由于编解码器/分辨率/视频轨道类型不匹配、优先级整数无效或超过每个直播的最大接管次数。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Stream 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:channel/12345678-1a23-4567-a1bc-1a2b34567890" ], "detail": { "event_name": "Stream Takeover Failure", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn", "code": "StreamTakeoverInvalidPriority" } }
示例:流运行状况更改
资源匮乏开始:当流未从流播放器接收数据时,将发送此事件;该流被认为处于“资源匮乏”状态。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Stream Health 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:channel/12345678-1a23-4567-a1bc-1a2b34567890" ], "detail": { "event_name": "Starvation Start", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn" } }
资源匮乏结束:当资源匮乏的流开始从流播放器接收数据并且流再次运行正常时,将发送此事件。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Stream Health 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:channel/12345678-1a23-4567-a1bc-1a2b34567890" ], "detail": { "event_name": "Starvation End", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn" } }
示例:违反限制
所有违反限制事件都包括违反的限制的名称、限制值以及超出限制的数量(违反时的值减去限制)。
摄取比特率:当传入流的比特率超过 Amazon IVS 限制时,将发送此事件。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Limit Breach", "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:channel/12345678-1a23-4567-a1bc-1a2b34567890" ], "detail": { "limit_name": "Ingest Bitrate", "limit_value": 1234, "exceeded_by": 3, "limit_unit": "bits per second", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn" } }
摄取分辨率:当传入流的分辨率(像素总数或每个边缘的像素)超过 Amazon IVS 限制时,将发送此事件。
超出最大像素总数:
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Limit Breach", "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:channel/12345678-1a23-4567-a1bc-1a2b34567890" ], "detail": { "limit_name": "Ingest Resolution", "limit_value": 495000, "exceeded_by": 426600, "limit_unit": "total pixels", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn" } }
超出每个边缘的最大像素数:
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Limit Breach", "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:channel/12345678-1a23-4567-a1bc-1a2b34567890"TBD ], "detail": { "limit_name": "Ingest Resolution", "limit_value": 855, "exceeded_by": 45, "limit_unit": "pixels per edge", "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn" } }
并发广播:当同时进行流传输的通道总数超过 Amazon IVS 限制时,将发送此事件。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Limit Breach", "source": "aws.ivs", "account": "aws_account_id", "time": "2017-06-12T10:23:43Z", "region": "us-east-1", "resources": [], "detail": { "limit_name": "Concurrent Broadcasts", "limit_value": 2, "exceeded_by": 3, "limit_unit": "active streams" } }
并发查看器:当同时观看您通道的查看器总数超过 Amazon IVS 限制时,将发送此事件。
{ "version": "0", "id": "01234567-0123-0123-0123-012345678901", "detail-type": "IVS Limit Breach", "source": "aws.ivs", "account": "aws_account_id", "time": "2017-06-12T10:23:43Z", "region": "us-east-1", "resources": [], "detail": { "limit_name": "Concurrent Viewers", "limit_value": 10, "exceeded_by": 11, "limit_unit": "viewers" } }
示例:录制状态更改
对于所有录制状态更改事件,存储此直播所有对象的顶级路径为 recording_s3_key_prefix
。在失败的情况下,失败的原因是 recording_status_reason
。recording_duration_ms
字段是录制持续时间的毫秒数。
录制开始:当开始处理流并将片段写入为通道配置的存储位置时,将发送此事件。
{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Recording State Change", "source": "aws.ivs", "account": "123456789012", "time": "2020-06-23T20:12:36Z", "region": "us-west-2", "resources": [ "arn:aws:ivs:us-west-2:123456789012:channel/AbCdef1G2hij" ], "detail": { "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn", "recording_status": "Recording Start", "recording_status_reason": "", "recording_s3_bucket_name": "r2s3-dev-channel-1-recordings", "recording_s3_key_prefix": "ivs/v1/123456789012/AbCdef1G2hij/2020/6/23/20/12/j8Z9O91ndcVs", "recording_duration_ms": 0, "recording_session_id": "a6RfV23ES97iyfoQ" } }
录制结束:当流结束并停止此通道的录制时,将发送此事件。
{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Recording State Change", "source": "aws.ivs", "account": "123456789012", "time": "2020-06-24T07:51:32Z", "region": "us-west-2", "resources": [ "arn:aws:ivs:us-west-2:123456789012:channel/AbCdef1G2hij" ], "detail": { "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn", "recording_status": "Recording End", "recording_status_reason": "", "recording_s3_bucket_name": "r2s3-dev-channel-1-recordings", "recording_s3_key_prefix": "ivs/v1/123456789012/AbCdef1G2hij/2020/6/23/20/12/j8Z9O91ndcVs", "recording_duration_ms": 99370264, "recording_session_id": "a6RfV23ES97iyfoQ", "recording_session_stream_ids": ["st-254sopYUvi6F78ghpO9vn0A", "st-1A2b3c4D5e6F78ghij9Klmn"] } }
录制开启失败:当流开启但由于错误(例如,S3 存储桶不存在或不在正确的区域)而无法开启时,将发送此事件。此实时流不会被录制。
{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Recording State Change", "source": "aws.ivs", "account": "123456789012", "time": "2020-06-23T20:12:36Z", "region": "us-west-2", "resources": [ "arn:aws:ivs:us-west-2:123456789012:channel/AbCdef1G2hij" ], "detail": { "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn", "recording_status": "Recording Start Failure", "recording_status_reason": "ValidationException", "recording_s3_bucket_name": "r2s3-dev-channel-1-recordings", "recording_s3_key_prefix": "", "recording_duration_ms": 0, "recording_session_id": "a6RfV23ES97iyfoQ" } }
录制结束失败:由于录制过程中遇到错误,录制结束失败时会发送此事件。某些对象可能仍会写入已配置的存储位置。
{ "version": "0", "id": "12345678-1a23-4567-a1bc-1a2b34567890", "detail-type": "IVS Recording State Change", "source": "aws.ivs", "account": "123456789012", "time": "2020-06-24T07:51:32Z", "region": "us-west-2", "resources": [ "arn:aws:ivs:us-west-2:123456a7-ab1c-2d34-e5f6-1a2b3c4d5678" ], "detail": { "channel_name": "Your Channel", "stream_id": "st-1A2b3c4D5e6F78ghij9Klmn", "recording_status": "Recording End Failure", "recording_status_reason": "InternalServerException", "recording_s3_bucket_name": "r2s3-dev-channel-1-recordings", "recording_s3_key_prefix": "ivs/v1/123456789012/AbCdef1G2hij/2020/6/23/20/12/j8Z9O91ndcVs", "recording_duration_ms": 0, "recording_session_id": "a6RfV23ES97iyfoQ" } }