搭配 IVS 即時串流使用 Amazon EventBridge
您可以使用 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 使用者指南中的在 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" } }