Google Cloud Video Intelligence Operators


CloudVideoIntelligenceDetectVideoLabelsOperator

Performs video annotation, annotating video labels.

For parameter definition, take a look atairflow.contrib.operators.gcp_video_intelligence_operator.CloudVideoIntelligenceDetectVideoLabelsOperator

Arguments

Some arguments in the example DAG are taken from the OS environment variables:

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW SOURCE

GCP_BUCKET_NAME = os.environ.get(
    "GCP_VIDEO_INTELLIGENCE_BUCKET_NAME", "test-bucket-name"
)

Input uri is an uri to a file in Google Cloud Storage

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW SOURCE

INPUT_URI = "gs://{}/video.mp4".format(GCP_BUCKET_NAME)

Using the operator

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW SOURCE

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

You can use the annotation output via Xcom:

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW 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",
)

Templating

template_fields = ("input_uri", "output_uri", "gcp_conn_id")

More information

Note: The duration of video annotation operation is equal or longer than the annotation video itself.

CloudVideoIntelligenceDetectVideoExplicitContentOperator

Performs video annotation, annotating explicit content.

For parameter definition, take a look atairflow.contrib.operators.gcp_video_intelligence_operator.CloudVideoIntelligenceDetectVideoExplicitContentOperator

Arguments

Some arguments in the example DAG are taken from the OS environment variables:

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW SOURCE

GCP_BUCKET_NAME = os.environ.get(
    "GCP_VIDEO_INTELLIGENCE_BUCKET_NAME", "test-bucket-name"
)

Input uri is an uri to a file in Google Cloud Storage

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW SOURCE

INPUT_URI = "gs://{}/video.mp4".format(GCP_BUCKET_NAME)

Using the operator

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW 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",
)

You can use the annotation output via Xcom:

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW 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",
)

Templating

template_fields = ("input_uri", "output_uri", "gcp_conn_id")

More information

Note: The duration of video annotation operation is equal or longer than the annotation video itself.

CloudVideoIntelligenceDetectVideoShotsOperator

Performs video annotation, annotating explicit content.

For parameter definition, take a look atairflow.contrib.operators.gcp_video_intelligence_operator.CloudVideoIntelligenceDetectVideoShotsOperator

Arguments

Some arguments in the example DAG are taken from the OS environment variables:

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW SOURCE

GCP_BUCKET_NAME = os.environ.get(
    "GCP_VIDEO_INTELLIGENCE_BUCKET_NAME", "test-bucket-name"
)

Input uri is an uri to a file in Google Cloud Storage

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW SOURCE

INPUT_URI = "gs://{}/video.mp4".format(GCP_BUCKET_NAME)

Using the operator

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW 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",
)

You can use the annotation output via Xcom:

airflow/contrib/example_dags/example_gcp_video_intelligence.pyVIEW 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",
)

Templating

template_fields = ("input_uri", "output_uri", "gcp_conn_id")

More information

Note: The duration of video annotation operation is equal or longer than the annotation video itself.