如要使用應用程式分析影片資料,第一步是建立管道,持續傳輸資料。Streams 可擷取即時視訊資料,然後做為模型輸入內容或儲存在倉儲中。
建立訊息串
如要串流影片資料,請先建立串流。
在新的專案中首次建立串流時,可能需要一些時間。 這段時間約為 30 分鐘。這是因為系統需要初始化運算叢集,才能進行後續運算。
控制台
在 Google Cloud 控制台中建立串流。
開啟 Gemini Enterprise Agent Platform Vision 資訊主頁的「Streams」分頁。
按一下「註冊」。
輸入串流名稱並選取區域。按一下「新增資料列」,即可同時註冊多個串流。
按一下「註冊」按鈕,建立一或多個串流。
擷取影片
建立串流後,即可開始使用該串流擷取資料。
擷取的影片須遵守下列限制和注意事項:
- 輸入影片來源必須符合下列規格:
- H.264 編碼
- 解析度最高 1080p
- 約 25 FPS
如果影片不符合這些規格,Gemini Enterprise Agent Platform Vision 可能無法順利處理輸入內容。
- 擷取期間音訊遭到捨棄。
- 如果串流是連結至倉庫的應用程式的一部分,則整個串流的影片參數 (例如 FPS 或解析度) 必須相同;系統不支援 RTSP 影片資料參數或本機影片資料參數的變化。
- 由於模型啟動延遲,系統可能無法擷取影片開頭幾秒的內容。最多可達 15 秒。
- 如果連線時間過長 (平均約 5 小時),系統可能會終止擷取作業。這項工具無法重新連線,使用者必須手動重新連線。
vaictl - 雖然
vaictl是擷取影片資料的實用工具,但無法自動處理網路錯誤的復原作業。這些錯誤可能來自資料來源端或 Cloud 擷取端。使用者有責任建立重新啟動指令碼,處理非預期的vaictl作業終止情況。
Gemini Enterprise Agent Platform Vision SDK
如要使用現有串流傳送要求來擷取影片資料,請安裝 Gemini Enterprise Agent Platform Vision SDK。
請替換下列變數:
- PROJECT_ID: Google Cloud 專案 ID。
- LOCATION_ID:您的地區 ID。例如:
us-central1。更多資訊。支援的地區。 - LOCAL_FILE.EXT:本機影片檔案的檔案名稱。例如:
my-video.mp4。 - STREAM_ID:您在叢集中建立的串流 ID,例如
input-1。 - RTSP_ADDRESS:即時串流通訊協定 (RTSP) 動態消息的地址。例如:
rtsp://my-ip-camera。
本機影片資料:
# This command streams a video file to a stream. Streaming ends when the video ends.
vaictl -p PROJECT_ID \
-l LOCATION_ID \
-c application-cluster-0 \
--service-endpoint visionai.googleapis.com \
send video-file to streams STREAM_ID --file-path LOCAL_FILE.EXT
本機影片資料 (循環播放):
# This command streams a video file to a stream. Video is looped into the stream until you stop the command.
vaictl -p PROJECT_ID \
-l LOCATION_ID \
-c application-cluster-0 \
--service-endpoint visionai.googleapis.com \
send video-file to streams STREAM_ID --file-path LOCAL_FILE.EXT --loop
即時串流通訊協定 (RTSP) 饋給資料:
# This command will send an RTSP feed into the stream.
# This command has to run in the network that has direct access to the RTSP feed.
vaictl -p PROJECT_ID \
-l LOCATION_ID \
-c application-cluster-0 \
--service-endpoint visionai.googleapis.com \
send rtsp to streams STREAM_ID --rtsp-uri RTSP_ADDRESS
播放已擷取的影片
建立串流並將影片內容傳送至串流後,即可播放影片內容。
如果串流檢視分頁開啟超過一小時,請務必重新整理頁面,才能繼續載入影片內容。
控制台
在 Google Cloud 控制台中播放擷取的影片。
開啟 Gemini Enterprise Agent Platform Vision 資訊主頁的「Streams」分頁。
在串流清單中,按一下串流名稱。
在影片串流詳細資料頁面中,系統會自動載入擷取的影片即時檢視畫面。