如要使用應用程式分析影片資料,第一步是建立持續傳輸資料的管道。Streams 可擷取即時影片資料,並將其做為模型輸入內容,或儲存在 Warehouse。
建立串流
您必須先建立串流,才能串流傳輸影片資料。
在新的專案中首次建立串流時,可能需要一些時間才能完成。這項作業可能需要 30 分鐘才能完成。這是因為系統需要初始化運算叢集,才能進行後續運算。
控制台
在 Google Cloud 控制台建立串流。
開啟 Gemini Enterprise Agent Platform Vision 資訊主頁的「Streams」(串流) 分頁。
按一下「 註冊」。
輸入串流名稱並選取區域。您可以按一下「Add Row」(新增資料列),同時註冊多個串流。
按一下「Register」(註冊) 按鈕,建立一或多個串流。
擷取影片
建立串流後,您就可以開始使用該串流擷取資料。
擷取影片時,請留意下列限制和注意事項:
- 輸入影片來源必須符合下列規格:
- H.264 編碼
- 解析度 <= 1080p
- ~25 FPS
如果影片不符合這些規格,Gemini Enterprise Agent Platform Vision 可能無法妥善處理輸入內容。
- 擷取期間音訊中斷。
- 如果串流屬於連結至倉儲的應用程式,則整個串流的影片參數 (例如每秒影格數或解析度) 必須相同;不支援 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」(串流) 分頁。
在串流清單中,按一下串流名稱。
在影片串流詳細資料頁面中,系統會自動載入擷取的影片即時畫面。