|
| 1 | +resource "google_storage_bucket" "default" { |
| 2 | + name = "transcoder-job-${local.name_suffix}" |
| 3 | + location = "US" |
| 4 | + force_destroy = true |
| 5 | + |
| 6 | + uniform_bucket_level_access = true |
| 7 | + public_access_prevention = "enforced" |
| 8 | +} |
| 9 | + |
| 10 | +resource "google_storage_bucket_object" "example_mp4" { |
| 11 | + name = "example.mp4" |
| 12 | + source = "./test-fixtures/example.mp4" |
| 13 | + bucket = google_storage_bucket.default.name |
| 14 | +} |
| 15 | + |
| 16 | +resource "google_transcoder_job" "default" { |
| 17 | + location = "us-central1" |
| 18 | + |
| 19 | + config { |
| 20 | + inputs { |
| 21 | + key = "input0" |
| 22 | + uri = "gs://${google_storage_bucket.default.name}/${google_storage_bucket_object.example_mp4.name}" |
| 23 | + } |
| 24 | + |
| 25 | + edit_list { |
| 26 | + key = "atom0" |
| 27 | + start_time_offset = "0s" |
| 28 | + inputs = ["input0"] |
| 29 | + } |
| 30 | + |
| 31 | + ad_breaks { |
| 32 | + start_time_offset = "3.500s" |
| 33 | + } |
| 34 | + |
| 35 | + elementary_streams { |
| 36 | + key = "video-stream0" |
| 37 | + video_stream { |
| 38 | + h264 { |
| 39 | + width_pixels = 640 |
| 40 | + height_pixels = 360 |
| 41 | + bitrate_bps = 550000 |
| 42 | + frame_rate = 60 |
| 43 | + pixel_format = "yuv420p" |
| 44 | + rate_control_mode = "vbr" |
| 45 | + crf_level = 21 |
| 46 | + gop_duration = "3s" |
| 47 | + vbv_size_bits = 550000 |
| 48 | + vbv_fullness_bits = 495000 |
| 49 | + entropy_coder = "cabac" |
| 50 | + profile = "high" |
| 51 | + preset = "veryfast" |
| 52 | + |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + elementary_streams { |
| 58 | + key = "video-stream1" |
| 59 | + video_stream { |
| 60 | + h264 { |
| 61 | + width_pixels = 1280 |
| 62 | + height_pixels = 720 |
| 63 | + bitrate_bps = 550000 |
| 64 | + frame_rate = 60 |
| 65 | + pixel_format = "yuv420p" |
| 66 | + rate_control_mode = "vbr" |
| 67 | + crf_level = 21 |
| 68 | + gop_duration = "3s" |
| 69 | + vbv_size_bits = 2500000 |
| 70 | + vbv_fullness_bits = 2250000 |
| 71 | + entropy_coder = "cabac" |
| 72 | + profile = "high" |
| 73 | + preset = "veryfast" |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + elementary_streams { |
| 79 | + key = "audio-stream0" |
| 80 | + audio_stream { |
| 81 | + codec = "aac" |
| 82 | + bitrate_bps = 64000 |
| 83 | + channel_count = 2 |
| 84 | + channel_layout = ["fl", "fr"] |
| 85 | + sample_rate_hertz = 48000 |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + mux_streams { |
| 90 | + key = "sd" |
| 91 | + file_name = "sd.mp4" |
| 92 | + container = "mp4" |
| 93 | + elementary_streams = ["video-stream0", "audio-stream0"] |
| 94 | + } |
| 95 | + |
| 96 | + mux_streams { |
| 97 | + key = "hd" |
| 98 | + file_name = "hd.mp4" |
| 99 | + container = "mp4" |
| 100 | + elementary_streams = ["video-stream1", "audio-stream0"] |
| 101 | + } |
| 102 | + |
| 103 | + mux_streams { |
| 104 | + key = "media-sd" |
| 105 | + file_name = "media-sd.ts" |
| 106 | + container = "ts" |
| 107 | + elementary_streams = ["video-stream0", "audio-stream0"] |
| 108 | + } |
| 109 | + |
| 110 | + mux_streams { |
| 111 | + key = "media-hd" |
| 112 | + file_name = "media-hd.ts" |
| 113 | + container = "ts" |
| 114 | + elementary_streams = ["video-stream1", "audio-stream0"] |
| 115 | + } |
| 116 | + |
| 117 | + mux_streams { |
| 118 | + key = "video-only-sd" |
| 119 | + file_name = "video-only-sd.m4s" |
| 120 | + container = "fmp4" |
| 121 | + elementary_streams = ["video-stream0"] |
| 122 | + } |
| 123 | + |
| 124 | + mux_streams { |
| 125 | + key = "video-only-hd" |
| 126 | + file_name = "video-only-hd.m4s" |
| 127 | + container = "fmp4" |
| 128 | + elementary_streams = ["video-stream1"] |
| 129 | + } |
| 130 | + |
| 131 | + mux_streams { |
| 132 | + key = "audio-only" |
| 133 | + file_name = "audio-only.m4s" |
| 134 | + container = "fmp4" |
| 135 | + elementary_streams = ["audio-stream0"] |
| 136 | + } |
| 137 | + |
| 138 | + manifests { |
| 139 | + file_name = "manifest.m3u8" |
| 140 | + type = "HLS" |
| 141 | + mux_streams = ["media-sd", "media-hd"] |
| 142 | + } |
| 143 | + |
| 144 | + manifests { |
| 145 | + file_name = "manifest.mpd" |
| 146 | + type = "DASH" |
| 147 | + mux_streams = ["video-only-sd", "video-only-hd", "audio-only"] |
| 148 | + } |
| 149 | + |
| 150 | + output { |
| 151 | + uri = "gs://${google_storage_bucket.default.name}/outputs/" |
| 152 | + } |
| 153 | + } |
| 154 | + labels = { |
| 155 | + "label" = "key" |
| 156 | + } |
| 157 | +} |
0 commit comments