Google Cloud Video Intelligence Operators¶
Prerequisite Tasks¶
CloudVideoIntelligenceDetectVideoLabelsOperator¶
Performs video annotation, annotating video labels.
For parameter definition, take a look at
CloudVideoIntelligenceDetectVideoLabelsOperator
Using the operator¶
Input uri is an uri to a file in Google Cloud Storage
INPUT_URI = f"gs://{GCP_BUCKET_NAME}/video.mp4"
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:
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: Sequence[str] = (
"input_uri",
"output_uri",
"gcp_conn_id",
"impersonation_chain",
)
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 at
CloudVideoIntelligenceDetectVideoExplicitContentOperator
Arguments¶
Input uri is an uri to a file in Google Cloud Storage
INPUT_URI = f"gs://{GCP_BUCKET_NAME}/video.mp4"
Using the operator¶
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:
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: Sequence[str] = (
"input_uri",
"output_uri",
"gcp_conn_id",
"impersonation_chain",
)
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 at
CloudVideoIntelligenceDetectVideoShotsOperator
Arguments¶
Input uri is an uri to a file in Google Cloud Storage
INPUT_URI = f"gs://{GCP_BUCKET_NAME}/video.mp4"
Using the operator¶
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:
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: Sequence[str] = (
"input_uri",
"output_uri",
"gcp_conn_id",
"impersonation_chain",
)
More information¶
Note: The duration of video annotation operation is equal or longer than the annotation video itself.