Google Cloud Video Intelligence 運算子

先決條件任務

要使用這些運算子,您必須完成以下幾件事

CloudVideoIntelligenceDetectVideoLabelsOperator

執行影片註解,註解影片標籤。

參數定義請參閱 CloudVideoIntelligenceDetectVideoLabelsOperator

使用運算子

輸入 uri 是 Google Cloud Storage 中檔案的 uri

tests/system/google/cloud/video_intelligence/example_video_intelligence.py[source]

INPUT_URI = f"gs://{BUCKET_NAME_DST}/{FILE_NAME}"

tests/system/google/cloud/video_intelligence/example_video_intelligence.py[source]

detect_video_label = CloudVideoIntelligenceDetectVideoLabelsOperator(
    input_uri=INPUT_URI,
    output_uri=None,
    video_context=None,
    timeout=5,
    task_id="detect_video_label",
)

您可以透過 Xcom 使用註解輸出

tests/system/google/cloud/video_intelligence/example_video_intelligence.py[source]

detect_video_label_result = BashOperator(
    bash_command="echo {{ task_instance.xcom_pull('detect_video_label')"
    "['annotationResults'][0]['shotLabelAnnotations'][0]['entity']}}",
    task_id="detect_video_label_result",
)

範本化

template_fields: Sequence[str] = (
    "input_uri",
    "output_uri",
    "gcp_conn_id",
    "impersonation_chain",
)

更多資訊

注意:影片註解操作的持續時間等於或長於註解影片本身。

CloudVideoIntelligenceDetectVideoExplicitContentOperator

執行影片註解,註解不當內容。

參數定義請參閱 CloudVideoIntelligenceDetectVideoExplicitContentOperator

引數

輸入 uri 是 Google Cloud Storage 中檔案的 uri

tests/system/google/cloud/video_intelligence/example_video_intelligence.py[source]

INPUT_URI = f"gs://{BUCKET_NAME_DST}/{FILE_NAME}"

使用運算子

tests/system/google/cloud/video_intelligence/example_video_intelligence.py[source]

detect_video_explicit_content = CloudVideoIntelligenceDetectVideoExplicitContentOperator(
    input_uri=INPUT_URI,
    output_uri=None,
    video_context=None,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="detect_video_explicit_content",
)

您可以透過 Xcom 使用註解輸出

tests/system/google/cloud/video_intelligence/example_video_intelligence.py[source]

detect_video_explicit_content_result = BashOperator(
    bash_command="echo {{ task_instance.xcom_pull('detect_video_explicit_content')"
    "['annotationResults'][0]['explicitAnnotation']['frames'][0]}}",
    task_id="detect_video_explicit_content_result",
)

範本化

template_fields: Sequence[str] = (
    "input_uri",
    "output_uri",
    "gcp_conn_id",
    "impersonation_chain",
)

更多資訊

注意:影片註解操作的持續時間等於或長於註解影片本身。

CloudVideoIntelligenceDetectVideoShotsOperator

執行影片註解,註解不當內容。

參數定義請參閱 CloudVideoIntelligenceDetectVideoShotsOperator

引數

輸入 uri 是 Google Cloud Storage 中檔案的 uri

tests/system/google/cloud/video_intelligence/example_video_intelligence.py[source]

INPUT_URI = f"gs://{BUCKET_NAME_DST}/{FILE_NAME}"

使用運算子

tests/system/google/cloud/video_intelligence/example_video_intelligence.py[source]

detect_video_shots = CloudVideoIntelligenceDetectVideoShotsOperator(
    input_uri=INPUT_URI,
    output_uri=None,
    video_context=None,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="detect_video_shots",
)

您可以透過 Xcom 使用註解輸出

tests/system/google/cloud/video_intelligence/example_video_intelligence.py[source]

detect_video_shots_result = BashOperator(
    bash_command="echo {{ task_instance.xcom_pull('detect_video_shots')"
    "['annotationResults'][0]['shotAnnotations'][0]}}",
    task_id="detect_video_shots_result",
)

範本化

template_fields: Sequence[str] = (
    "input_uri",
    "output_uri",
    "gcp_conn_id",
    "impersonation_chain",
)

更多資訊

注意:影片註解操作的持續時間等於或長於註解影片本身。

參考

更多資訊請參閱

這個條目對您有幫助嗎?