Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Google Transcoder API #10932

Merged
merged 6 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
571 changes: 571 additions & 0 deletions mmv1/products/transcoder/Job.yaml

Large diffs are not rendered by default.

520 changes: 520 additions & 0 deletions mmv1/products/transcoder/JobTemplate.yaml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions mmv1/products/transcoder/product.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
name: 'Transcoder'
display_name: 'Transcoder'
versions:
- name: 'ga'
base_url: 'https://transcoder.googleapis.com/v1/'
scopes:
- 'https://www.googleapis.com/auth/cloud-platform'
108 changes: 108 additions & 0 deletions mmv1/templates/terraform/examples/transcoder_job_basic.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
resource "google_storage_bucket" "default" {
name = "{{index $.Vars "bucket_name"}}"
location = "US"
force_destroy = true

uniform_bucket_level_access = true
public_access_prevention = "enforced"
}

resource "google_storage_bucket_object" "example_mp4" {
name = "example.mp4"
source = "./test-fixtures/example.mp4"
bucket = google_storage_bucket.default.name
}

resource "google_transcoder_job" "{{$.PrimaryResourceId}}" {
template_id = google_transcoder_job_template.default.name
location = "us-central1"

labels = {
"label" = "key"
}
}

resource "google_transcoder_job_template" "default" {
job_template_id = "{{index $.Vars "job_template_id"}}"
location = "us-central1"
config {
inputs {
key = "input0"
uri = "gs://${google_storage_bucket.default.name}/${google_storage_bucket_object.example_mp4.name}"
}
output {
uri = "gs://${google_storage_bucket.default.name}/outputs/"
}
edit_list {
key = "atom0"
inputs = ["input0"]
start_time_offset = "0s"
}
elementary_streams {
key = "video-stream0"
video_stream {
h264 {
width_pixels = 640
height_pixels = 360
bitrate_bps = 550000
frame_rate = 60
pixel_format = "yuv420p"
rate_control_mode = "vbr"
crf_level = 21
gop_duration = "3s"
vbv_size_bits = 550000
vbv_fullness_bits = 495000
entropy_coder = "cabac"
profile = "high"
preset = "veryfast"

}
}
}
elementary_streams {
key = "video-stream1"
video_stream {
h264 {
width_pixels = 1280
height_pixels = 720
bitrate_bps = 550000
frame_rate = 60
pixel_format = "yuv420p"
rate_control_mode = "vbr"
crf_level = 21
gop_duration = "3s"
vbv_size_bits = 2500000
vbv_fullness_bits = 2250000
entropy_coder = "cabac"
profile = "high"
preset = "veryfast"
}
}
}
elementary_streams {
key = "audio-stream0"
audio_stream {
codec = "aac"
bitrate_bps = 64000
channel_count = 2
channel_layout = ["fl", "fr"]
sample_rate_hertz = 48000
}
}
mux_streams {
key = "sd"
file_name = "sd.mp4"
container = "mp4"
elementary_streams = ["video-stream0", "audio-stream0"]
}
mux_streams {
key = "hd"
file_name = "hd.mp4"
container = "mp4"
elementary_streams = ["video-stream1", "audio-stream0"]
}
}
labels = {
"label" = "key"
}
}
181 changes: 181 additions & 0 deletions mmv1/templates/terraform/examples/transcoder_job_encryptions.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
resource "google_storage_bucket" "default" {
name = "{{index $.Vars "bucket_name"}}"
location = "US"
force_destroy = true

uniform_bucket_level_access = true
public_access_prevention = "enforced"
provider = google-beta
}

resource "google_storage_bucket_object" "example_mp4" {
name = "example.mp4"
source = "./test-fixtures/example.mp4"
bucket = google_storage_bucket.default.name
provider = google-beta
}

resource "google_secret_manager_secret" "encryption_key" {
secret_id = "{{index $.Vars "secret_manager_secret_id"}}"
replication {
auto {}
}
provider = google-beta
}

resource "google_secret_manager_secret_version" "encryption_key" {
secret = google_secret_manager_secret.encryption_key.name
secret_data = "4A67F2C1B8E93A4F6D3E7890A1BC23DF"
provider = google-beta
}

data "google_project" "project" {
provider = google-beta
}

# this is required to allow the transcoder service identity to access the secret
resource "google_project_service_identity" "transcoder" {
project = data.google_project.project.project_id
service = "transcoder.googleapis.com"
provider = google-beta
}

resource "google_secret_manager_secret_iam_member" "transcoder_encryption_key_accessor" {
secret_id = google_secret_manager_secret.encryption_key.secret_id
project = google_secret_manager_secret.encryption_key.project
role = "roles/secretmanager.secretAccessor"
member = "serviceAccount:${google_project_service_identity.transcoder.email}"
provider = google-beta
}

resource "google_transcoder_job" "{{$.PrimaryResourceId}}" {
location = "us-central1"

config {
inputs {
key = "input0"
uri = "gs://${google_storage_bucket.default.name}/${google_storage_bucket_object.example_mp4.name}"
}
elementary_streams {
key = "es_video"
video_stream {
h264 {
profile = "main"
height_pixels = 600
width_pixels = 800
bitrate_bps = 1000000
frame_rate = 60
}
}
}
elementary_streams {
key = "es_audio"
audio_stream {
codec = "aac"
channel_count = 2
bitrate_bps = 160000
}
}
encryptions {
id = "aes-128"
secret_manager_key_source {
secret_version = google_secret_manager_secret_version.encryption_key.name
}
drm_systems {
clearkey {}
}
aes128 {}
}
encryptions {
id = "cenc"
secret_manager_key_source {
secret_version = google_secret_manager_secret_version.encryption_key.name
}
drm_systems {
widevine {}
}
mpeg_cenc {
scheme = "cenc"
}
}
encryptions {
id = "cbcs"
secret_manager_key_source {
secret_version = google_secret_manager_secret_version.encryption_key.name
}
drm_systems {
widevine {}
}
mpeg_cenc {
scheme = "cbcs"
}
}
mux_streams {
key = "ts_aes128"
container = "ts"
elementary_streams = ["es_video", "es_audio"]
segment_settings {
segment_duration = "6s"
}
encryption_id = "aes-128"
}
mux_streams {
key = "fmp4_cenc_video"
container = "fmp4"
elementary_streams = ["es_video"]
segment_settings {
segment_duration = "6s"
}
encryption_id = "cenc"
}
mux_streams {
key = "fmp4_cenc_audio"
container = "fmp4"
elementary_streams = ["es_audio"]
segment_settings {
segment_duration = "6s"
}
encryption_id = "cenc"
}
mux_streams {
key = "fmp4_cbcs_video"
container = "fmp4"
elementary_streams = ["es_video"]
segment_settings {
segment_duration = "6s"
}
encryption_id = "cbcs"
}
mux_streams {
key = "fmp4_cbcs_audio"
container = "fmp4"
elementary_streams = ["es_audio"]
segment_settings {
segment_duration = "6s"
}
encryption_id = "cbcs"
}
manifests {
file_name = "manifest_aes128.m3u8"
type = "HLS"
mux_streams = ["ts_aes128"]
}
manifests {
file_name = "manifest_cenc.mpd"
type = "DASH"
mux_streams = ["fmp4_cenc_video", "fmp4_cenc_audio"]
}
manifests {
file_name = "manifest_cbcs.mpd"
type = "DASH"
mux_streams = ["fmp4_cbcs_video", "fmp4_cbcs_audio"]
}
output {
uri = "gs://${google_storage_bucket.default.name}/outputs/"
}
}
labels = {
"label" = "key"
}
provider = google-beta
}
Loading
Loading