bitmovin-ruby 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +1 -1
  4. data/examples/create_encoding_finished_webhook.rb +21 -0
  5. data/examples/dash_hls_mp4_encoding_with_manifests.rb +502 -0
  6. data/examples/hls_multi_codec.rb +205 -0
  7. data/examples/simple_dash_with_http_input.rb +216 -0
  8. data/examples/simple_hls_with_aes128.rb +197 -0
  9. data/lib/bitmovin/encoding/codec_configurations/h265_configuration.rb +1 -0
  10. data/lib/bitmovin/encoding/encodings/muxings/drms/drm_muxing_resource.rb +54 -0
  11. data/lib/bitmovin/encoding/encodings/muxings/drms/drm_muxings.rb +6 -0
  12. data/lib/bitmovin/encoding/encodings/muxings/drms/ts_muxing_aes_encryption.rb +5 -0
  13. data/lib/bitmovin/encoding/encodings/muxings/drms/ts_muxing_aes_encryption_list.rb +15 -0
  14. data/lib/bitmovin/encoding/encodings/muxings/drms/ts_muxing_drm_list.rb +11 -0
  15. data/lib/bitmovin/encoding/encodings/muxings/mp4_muxing_list.rb +1 -1
  16. data/lib/bitmovin/encoding/encodings/muxings/ts_muxing.rb +15 -0
  17. data/lib/bitmovin/encoding/encodings/stream.rb +6 -1
  18. data/lib/bitmovin/encoding/encodings.rb +4 -0
  19. data/lib/bitmovin/encoding/inputs.rb +18 -0
  20. data/lib/bitmovin/encoding/manifests/hls_audio_media.rb +27 -0
  21. data/lib/bitmovin/encoding/manifests/hls_manifest.rb +43 -0
  22. data/lib/bitmovin/encoding/manifests/hls_variant_stream.rb +20 -0
  23. data/lib/bitmovin/encoding/manifests/hls_variant_stream_list.rb +22 -0
  24. data/lib/bitmovin/encoding/manifests/list.rb +39 -0
  25. data/lib/bitmovin/encoding/manifests.rb +3 -0
  26. data/lib/bitmovin/encoding/outputs.rb +2 -0
  27. data/lib/bitmovin/version.rb +1 -1
  28. data/lib/bitmovin/webhooks/encoding_finished_webhook.rb +5 -0
  29. data/lib/bitmovin/webhooks/webhook_encryption.rb +45 -0
  30. data/lib/bitmovin/webhooks/webhook_resource.rb +5 -0
  31. data/lib/bitmovin/webhooks/webhook_signature.rb +45 -0
  32. data/lib/bitmovin/webhooks.rb +8 -0
  33. data/lib/bitmovin-ruby.rb +1 -0
  34. metadata +22 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45b37ec43acfba76cfe20cfa6d5e7241c2cf975e
4
- data.tar.gz: e6f42b701acc7fe70596dc9b58207ed775622e96
3
+ metadata.gz: 5de44e18db229a82ee80c332b3aee2728351fcde
4
+ data.tar.gz: c61b99260159081c6727925c5f6dd1704af4e887
5
5
  SHA512:
6
- metadata.gz: 99f8c6f75bf858b56e2e9b4d0ad6f7e8645481a56defc78359397c2e59526eb1bb25943dda6f960769f5743294deaf93ca5d5a1cf614c8b64cc1235f945378ea
7
- data.tar.gz: b7517a96af4228181d58f2f3eb49cd78d386005b49c9b021a6223625c7ee890dbf0a610f9e6c53b6e431665dc180daf5d0de08724d4d9ca17c7fd893afff68bd
6
+ metadata.gz: f2ee0b359e8cc3edc9a6da8c0962cfef95ff56a7fa9ba3188d43179d0dbae38fc8788ece33e0f3486156541fb565663f067ed2d765e4f8f311254bfe2b6837cd
7
+ data.tar.gz: c56d66a39a98fd244ba6aeb5da50b408141a1ca52657a5d0c781bf0054a7f37f477619f2ddca41c4d98452ed1f90430710da3f89222e777f358f6ac19cc6d80c
data/.gitignore CHANGED
@@ -11,3 +11,5 @@ test-manifest.rb
11
11
  test_encoding.rb
12
12
  delete.rb
13
13
  *.gem
14
+ examples/*_customer.rb
15
+ .idea
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Bitmovin::Ruby API Client
1
+ # [![bitmovin](http://bitmovin-a.akamaihd.net/webpages/bitmovin-logo-github.png)](http://www.bitmovin.com) Bitmovin::Ruby API Client
2
2
  [![codecov](https://codecov.io/gh/bitmovin/bitmovin-ruby/branch/develop/graph/badge.svg)](https://codecov.io/gh/bitmovin/bitmovin-ruby)
3
3
  [![Build Status](https://travis-ci.org/bitmovin/bitmovin-ruby.svg?branch=develop)](https://travis-ci.org/bitmovin/bitmovin-ruby)
4
4
 
@@ -0,0 +1,21 @@
1
+ require 'bitmovin-ruby'
2
+
3
+ # Adding finished webhook to encoding
4
+ finished_webhook = Bitmovin::Webhooks::EncodingFinishedWebhook.new(
5
+ {
6
+ method: 'POST',
7
+ insecure_ssl: 'false',
8
+ url: 'http://httpbin.org/post',
9
+ encryption: Bitmovin::Webhooks::WebhookEncryption.new({
10
+ key: 'mySecretKey',
11
+ type: 'AES'
12
+ }),
13
+ signature: Bitmovin::Webhooks::WebhookSignature.new({
14
+ key: 'mySecretKey',
15
+ type: 'HMAC'
16
+ })
17
+ }
18
+ )
19
+
20
+ finished_webhook.save!
21
+ puts "Added finished webkook with id #{finished_webhook.id}!"
@@ -0,0 +1,502 @@
1
+ require 'bitmovin-ruby'
2
+
3
+ # CONFIGURATION
4
+ BITMOVIN_API_KEY = 'YOUR API KEY HERE'
5
+
6
+ S3_INPUT_ID = 'The ID of the Input'
7
+ S3_OUTPUT_ID = 'The ID of the Output'
8
+ OUTPUT_PATH = "/encoding_test/bitmovin-ruby/#{Time.now.strftime('%v-%H-%M')}/"
9
+ INPUT_FILE_PATH = 'your_input_file_name'
10
+
11
+ Bitmovin.init(BITMOVIN_API_KEY)
12
+
13
+ # This will create a Input Bucket you can reuse in future encodings
14
+ # To get a list of all your S3Inputs do:
15
+ # Bitmovin::Encoding::Inputs::S3Input.list
16
+ s3_input = Bitmovin::Encoding::Inputs::S3Input.find(S3_INPUT_ID)
17
+
18
+ # This will create a Output Bucket you can reuse in future encodings
19
+ # To get a list of all your Output do:
20
+ # Bitmovin::Encoding::Outputs::S3Output.list
21
+ s3_output = Bitmovin::Encoding::Outputs::S3Output.find(S3_OUTPUT_ID)
22
+
23
+ # Please note inputs/outputs are not individual files but rather the
24
+ # Bucket you are reading/writing files to and they can be reused between encodings.
25
+
26
+
27
+ # This hash contains the H264 Codec Configurations we want to create
28
+ # Codec Configurations are similar to Inputs/Outputs in that they are configured once
29
+ # and can be reused for future encodings.
30
+ video_configs = [
31
+ {name: 'h264_360p_600', profile: 'HIGH', height: 360, bitrate: 600000},
32
+ {name: 'h264_432p_700', profile: 'HIGH', height: 432, bitrate: 700000},
33
+ {name: 'h264_576p_1050', profile: 'HIGH', height: 576, bitrate: 1050000},
34
+ {name: 'h264_720p_1380', profile: 'HIGH', height: 720, bitrate: 1380000},
35
+ {name: 'h264_720p_1800', profile: 'HIGH', height: 720, bitrate: 1800000},
36
+ {name: 'h264_1080p_2150', profile: 'HIGH', height: 1080, bitrate: 2150000},
37
+ {name: 'h264_1080p_2900', profile: 'HIGH', height: 1080, bitrate: 2900000},
38
+ {name: 'h264_2160p_4000', profile: 'HIGH', height: 2160, bitrate: 4000000},
39
+ {name: 'h264_2160p_6000', profile: 'HIGH', height: 2160, bitrate: 6000000},
40
+ {name: 'h264_2160p_8500', profile: 'HIGH', height: 2160, bitrate: 8500000},
41
+ {name: 'h264_2160p_10000', profile: 'HIGH', height: 2160, bitrate: 10000000},
42
+
43
+ {name: 'h265_360p_420', profile: 'main', height: 360, bitrate: 420000},
44
+ {name: 'h265_432p_490', profile: 'main', height: 432, bitrate: 490000},
45
+ {name: 'h265_576p_735', profile: 'main', height: 576, bitrate: 735000},
46
+ {name: 'h265_720p_966', profile: 'main', height: 720, bitrate: 966000},
47
+ {name: 'h265_720p_1260', profile: 'main', height: 720, bitrate: 1260000},
48
+ {name: 'h265_1080p_1505', profile: 'main', height: 1080, bitrate: 1505000},
49
+ {name: 'h265_1080p_2030', profile: 'main', height: 1080, bitrate: 2030000},
50
+ {name: 'h265_2160p_2800', profile: 'main', height: 2160, bitrate: 2800000},
51
+ {name: 'h265_2160p_4200', profile: 'main', height: 2160, bitrate: 4200000},
52
+ {name: 'h265_2160p_5950', profile: 'main', height: 2160, bitrate: 5950000},
53
+ {name: 'h265_2160p_7000', profile: 'main', height: 2160, bitrate: 7000000}
54
+ ]
55
+
56
+ # The actual instance of the encoding task you are about to start
57
+ enc = Bitmovin::Encoding::Encodings::EncodingTask.new({
58
+ name: 'VOD h264/h265 Encoding HLS'
59
+ })
60
+ enc.save!
61
+
62
+ # Create or load the Audio Config
63
+ #audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.find("<EXISTING_AAC_CONFIG_ID>")
64
+ audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.new({
65
+ name: 'AAC_PROFILE_128k',
66
+ bitrate: 128000,
67
+ rate: 48000
68
+ })
69
+ audio_config.save!
70
+
71
+ # Adding Audio Stream to Encoding
72
+ audio_stream = enc.streams.build(name: 'audio stream')
73
+ audio_stream.codec_configuration = audio_config
74
+ audio_stream.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
75
+ audio_stream.conditions = {
76
+ type: 'CONDITION',
77
+ attribute: 'INPUTSTREAM',
78
+ operator: '==',
79
+ value: 'TRUE'
80
+ }
81
+ puts audio_stream.conditions.to_json
82
+ audio_stream.save!
83
+
84
+ # Audio Muxing
85
+ audio_muxing = enc.muxings.fmp4.build(name: 'audio-muxing', segment_length: 4)
86
+ audio_muxing.build_output({
87
+ output_id: s3_output.id,
88
+ output_path: File.join(OUTPUT_PATH, 'audio/aac')
89
+ })
90
+ audio_muxing.build_output({
91
+ output_id: s3_output.id,
92
+ output_path: File.join(OUTPUT_PATH, 'audio/aac'),
93
+ acl: [{
94
+ permission: 'PUBLIC_READ'
95
+ }]
96
+ })
97
+ audio_muxing.streams << audio_stream.id
98
+ audio_muxing.save!
99
+
100
+ # Let's also start the Manifest generation
101
+ # Multi Codec HLS Manifest
102
+ multi_hls_manifest = Bitmovin::Encoding::Manifests::HlsManifest.new({
103
+ name: 'Multi Codec HLS manifest',
104
+ description: 'Multi Codec HLS manifest',
105
+ manifest_name: 'multi_playlist.m3u8'
106
+ })
107
+
108
+ multi_hls_manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
109
+ output_id: s3_output.id,
110
+ output_path: OUTPUT_PATH
111
+ })
112
+ multi_hls_manifest.save!
113
+
114
+ multi_hls_manifest.build_audio_medium({
115
+ name: 'HLS Audio Media',
116
+ group_id: 'audio_group',
117
+ segment_path: 'audio/aac',
118
+ encoding_id: enc.id,
119
+ stream_id: audio_stream.id,
120
+ muxing_id: audio_muxing.id,
121
+ language: 'en',
122
+ uri: 'audio_media.m3u8'
123
+ }).save!
124
+
125
+ # H264 HLS Manifest
126
+ h264_hls_manifest = Bitmovin::Encoding::Manifests::HlsManifest.new({
127
+ name: 'H264 HLS manifest',
128
+ description: 'Multi Codec HLS manifest',
129
+ manifest_name: 'h264_playlist.m3u8'
130
+ })
131
+
132
+ h264_hls_manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
133
+ output_id: s3_output.id,
134
+ output_path: OUTPUT_PATH
135
+ })
136
+ h264_hls_manifest.save!
137
+
138
+ h264_hls_manifest.build_audio_medium({
139
+ name: 'HLS Audio Media',
140
+ group_id: 'audio_group',
141
+ segment_path: 'audio/aac',
142
+ encoding_id: enc.id,
143
+ stream_id: audio_stream.id,
144
+ muxing_id: audio_muxing.id,
145
+ language: 'en',
146
+ uri: 'audio_media.m3u8'
147
+ }).save!
148
+ # H265 HLS Manifest
149
+ h265_hls_manifest = Bitmovin::Encoding::Manifests::HlsManifest.new({
150
+ name: 'H265 HLS manifest',
151
+ description: 'Multi Codec HLS manifest',
152
+ manifest_name: 'h265_playlist.m3u8'
153
+ })
154
+
155
+ h265_hls_manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
156
+ output_id: s3_output.id,
157
+ output_path: OUTPUT_PATH
158
+ })
159
+ h265_hls_manifest.save!
160
+
161
+ h265_hls_manifest.build_audio_medium({
162
+ name: 'HLS Audio Media',
163
+ group_id: 'audio_group',
164
+ segment_path: 'audio/aac',
165
+ encoding_id: enc.id,
166
+ stream_id: audio_stream.id,
167
+ muxing_id: audio_muxing.id,
168
+ language: 'en',
169
+ uri: 'audio_media.m3u8'
170
+ }).save!
171
+
172
+ hls_manifests = [multi_hls_manifest, h264_hls_manifest, h265_hls_manifest]
173
+
174
+ # H264 DASH Manifest
175
+ h264_dash_manifest = Bitmovin::Encoding::Manifests::DashManifest.new({
176
+ name: 'H264 DASH Manifest',
177
+ description: 'H264 DASH Manifest',
178
+ manifest_name: 'h264_manifest.mpd'
179
+ })
180
+
181
+ h264_dash_manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
182
+ output_id: s3_output.id,
183
+ output_path: OUTPUT_PATH
184
+ })
185
+ h264_dash_manifest.save!
186
+
187
+ h264_period = Bitmovin::Encoding::Manifests::Period.new(
188
+ h264_dash_manifest.id
189
+ )
190
+ h264_period.save!
191
+
192
+ h264_video_adaptation_set = Bitmovin::Encoding::Manifests::VideoAdaptationSet.new(
193
+ h264_dash_manifest.id,
194
+ h264_period.id
195
+ )
196
+ h264_video_adaptation_set.save!
197
+
198
+ # Adding Audio Stream to H264 DASH Manifest
199
+ audio_adaptation_set = Bitmovin::Encoding::Manifests::AudioAdaptationSet.new(
200
+ h264_dash_manifest.id,
201
+ h264_period.id
202
+ )
203
+ audio_adaptation_set.save!
204
+
205
+ audio_adaptation_set.build_fmp4_representation({
206
+ encoding_id: enc.id,
207
+ muxing_id: audio_muxing.id,
208
+ segment_path: 'audio/aac',
209
+ type: 'TEMPLATE',
210
+ name: 'Audio Adaptation Set'
211
+
212
+ }).save!
213
+
214
+ # H265 DASH Manifest
215
+ h265_dash_manifest = Bitmovin::Encoding::Manifests::DashManifest.new({
216
+ name: 'H265 DASH Manifest',
217
+ description: 'H265 DASH Manifest',
218
+ manifest_name: 'h265_manifest.mpd'
219
+ })
220
+
221
+ h265_dash_manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
222
+ output_id: s3_output.id,
223
+ output_path: OUTPUT_PATH
224
+ })
225
+ h265_dash_manifest.save!
226
+
227
+ h265_period = Bitmovin::Encoding::Manifests::Period.new(
228
+ h265_dash_manifest.id
229
+ )
230
+ h265_period.save!
231
+
232
+ h265_video_adaptation_set = Bitmovin::Encoding::Manifests::VideoAdaptationSet.new(
233
+ h265_dash_manifest.id,
234
+ h265_period.id
235
+ )
236
+ h265_video_adaptation_set.save!
237
+
238
+ # Adding Audio Stream to H265 DASH Manifest
239
+ audio_adaptation_set = Bitmovin::Encoding::Manifests::AudioAdaptationSet.new(
240
+ h265_dash_manifest.id,
241
+ h265_period.id
242
+ )
243
+ audio_adaptation_set.save!
244
+
245
+ audio_adaptation_set.build_fmp4_representation({
246
+ encoding_id: enc.id,
247
+ muxing_id: audio_muxing.id,
248
+ segment_path: 'audio/aac',
249
+ type: 'TEMPLATE',
250
+ name: 'Audio Adaptation Set'
251
+
252
+ }).save!
253
+
254
+ # Multi Codec DASH manifest
255
+ multi_codec_dash_manifest = Bitmovin::Encoding::Manifests::DashManifest.new({
256
+ name: 'MULTI CODEC DASH Manifest',
257
+ description: 'MULTI CODEC DASH Manifest',
258
+ manifest_name: 'multi_codec_manifest.mpd'
259
+ })
260
+
261
+ multi_codec_dash_manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
262
+ output_id: s3_output.id,
263
+ output_path: OUTPUT_PATH
264
+ })
265
+ multi_codec_dash_manifest.save!
266
+
267
+ multi_codec_period = Bitmovin::Encoding::Manifests::Period.new(
268
+ multi_codec_dash_manifest.id
269
+ ).save!
270
+
271
+ multi_h265_adaptation_set = Bitmovin::Encoding::Manifests::VideoAdaptationSet.new(
272
+ multi_codec_dash_manifest.id,
273
+ multi_codec_period.id
274
+ ).save!
275
+
276
+ multi_h264_adaptation_set = Bitmovin::Encoding::Manifests::VideoAdaptationSet.new(
277
+ multi_codec_dash_manifest.id,
278
+ multi_codec_period.id
279
+ ).save!
280
+
281
+ # Adding Audio Stream to Multi Codec DASH Manifest
282
+ audio_adaptation_set = Bitmovin::Encoding::Manifests::AudioAdaptationSet.new(
283
+ multi_codec_dash_manifest.id,
284
+ multi_codec_period.id
285
+ ).save!
286
+
287
+ audio_adaptation_set.build_fmp4_representation({
288
+ encoding_id: enc.id,
289
+ muxing_id: audio_muxing.id,
290
+ segment_path: 'audio/aac',
291
+ type: 'TEMPLATE',
292
+ name: 'Audio Adaptation Set'
293
+
294
+ }).save!
295
+
296
+ dash_manifests = [multi_codec_dash_manifest, h264_dash_manifest, h265_dash_manifest]
297
+
298
+ def create_mp4(streams, name, enc, s3_output)
299
+ mp4_muxing = enc.muxings.mp4.build(name: "MP4 #{name} muxing", filename: "#{name}.mp4")
300
+ mp4_muxing.streams << streams.map {|stream| stream.id}
301
+ mp4_muxing.streams.flatten!
302
+ mp4_muxing.build_output({
303
+ output_id: s3_output.id,
304
+ output_path: File.join(OUTPUT_PATH, name),
305
+ acl: [{
306
+ permission: 'PUBLIC_READ'
307
+ }]
308
+ })
309
+
310
+ mp4_muxing.save!
311
+ puts "Added MP4 muxing #{mp4_muxing.name}"
312
+ end
313
+
314
+ # Adding Video Streams to Encoding
315
+ video_configs.each do |config|
316
+
317
+ if config[:name].start_with?('h264')
318
+ video_config_type = 'H264'
319
+ elsif config[:name].start_with?('h265')
320
+ video_config_type = 'H265'
321
+ else
322
+ video_config_type = 'NONE'
323
+ end
324
+
325
+ if video_config_type == 'H264'
326
+ codec_config = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new(config).save!
327
+ config = OpenStruct.new(config)
328
+
329
+ str = enc.streams.build(name: codec_config.name)
330
+ str.codec_configuration = codec_config
331
+ str.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
332
+ str.conditions = {
333
+ type: 'CONDITION',
334
+ attribute: 'HEIGHT',
335
+ operator: '>=',
336
+ value: codec_config.height
337
+ }
338
+ str.save!
339
+
340
+ create_mp4([str, audio_stream], codec_config.name, enc, s3_output)
341
+
342
+ fmp4_muxing = enc.muxings.fmp4.build(name: "#{codec_config.name} muxing", segment_length: 4)
343
+ fmp4_muxing.streams << str.id
344
+ fmp4_muxing.build_output({
345
+ output_id: s3_output.id,
346
+ output_path: File.join(OUTPUT_PATH, config.name),
347
+ acl: [{
348
+ permission: 'PUBLIC_READ'
349
+ }]
350
+ })
351
+ fmp4_muxing.save!
352
+ puts "Added FMP4 muxing #{fmp4_muxing.name}"
353
+
354
+ h264_video_adaptation_set.build_fmp4_representation(
355
+ encoding_id: enc.id,
356
+ muxing_id: fmp4_muxing.id,
357
+ type: 'TEMPLATE',
358
+ segment_path: config.name
359
+ ).save!
360
+ puts "Added muxing #{fmp4_muxing.name} to #{video_config_type} only DASH manifest"
361
+
362
+ multi_h264_adaptation_set.build_fmp4_representation(
363
+ encoding_id: enc.id,
364
+ muxing_id: fmp4_muxing.id,
365
+ type: 'TEMPLATE',
366
+ segment_path: config.name
367
+ ).save!
368
+ puts "Added muxing #{fmp4_muxing.name} to multi codec DASH manifest"
369
+
370
+ h264_hls_manifest.build_stream({
371
+ audio: 'audio_group',
372
+ closed_captions: 'NONE',
373
+ segmentPath: config.name,
374
+ encoding_id: enc.id,
375
+ muxing_id: fmp4_muxing.id,
376
+ stream_id: str.id,
377
+ uri: config.name + '.m3u8'
378
+ }).save!
379
+
380
+ puts "Added muxing #{fmp4_muxing.name} to #{video_config_type} HLS manifest"
381
+ else
382
+ codec_config = Bitmovin::Encoding::CodecConfigurations::H265Configuration.new(config)
383
+ codec_config.save!
384
+ config = OpenStruct.new(config)
385
+
386
+ str = enc.streams.build(name: codec_config.name)
387
+ str.codec_configuration = codec_config
388
+ str.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
389
+ str.conditions = {
390
+ type: 'CONDITION',
391
+ attribute: 'HEIGHT',
392
+ operator: '>=',
393
+ value: codec_config.height
394
+ }
395
+ str.save!
396
+
397
+ create_mp4([str, audio_stream], codec_config.name, enc, s3_output)
398
+
399
+ fmp4_muxing = enc.muxings.fmp4.build(name: "#{codec_config.name} muxing", segment_length: 4)
400
+ fmp4_muxing.streams << str.id
401
+ fmp4_muxing.build_output({
402
+ output_id: s3_output.id,
403
+ output_path: File.join(OUTPUT_PATH, config.name),
404
+ acl: [{
405
+ permission: 'PUBLIC_READ'
406
+ }]
407
+ })
408
+ fmp4_muxing.save!
409
+ puts "Added FMP4 muxing #{fmp4_muxing.name}"
410
+
411
+ h265_video_adaptation_set.build_fmp4_representation(
412
+ encoding_id: enc.id,
413
+ muxing_id: fmp4_muxing.id,
414
+ type: 'TEMPLATE',
415
+ segment_path: config.name
416
+ ).save!
417
+ puts "Added muxing #{fmp4_muxing.name} to #{video_config_type} only DASH manifest"
418
+
419
+ multi_h265_adaptation_set.build_fmp4_representation(
420
+ encoding_id: enc.id,
421
+ muxing_id: fmp4_muxing.id,
422
+ type: 'TEMPLATE',
423
+ segment_path: config.name
424
+ ).save!
425
+ puts "Added muxing #{fmp4_muxing.name} to multi codec DASH manifest"
426
+
427
+ h265_hls_manifest.build_stream({
428
+ audio: 'audio_group',
429
+ closed_captions: 'NONE',
430
+ segmentPath: config.name,
431
+ encoding_id: enc.id,
432
+ muxing_id: fmp4_muxing.id,
433
+ stream_id: str.id,
434
+ uri: config.name + '.m3u8'
435
+ }).save!
436
+
437
+ puts "Added muxing #{fmp4_muxing.name} to #{video_config_type} HLS manifest"
438
+ end
439
+
440
+ # Add the Stream to the multi codec HLS Manifest
441
+ multi_hls_manifest.build_stream({
442
+ audio: 'audio_group',
443
+ closed_captions: 'NONE',
444
+ segmentPath: config.name,
445
+ encoding_id: enc.id,
446
+ muxing_id: fmp4_muxing.id,
447
+ stream_id: str.id,
448
+ uri: config.name + '.m3u8'
449
+ }).save!
450
+
451
+ puts "Added muxing #{fmp4_muxing.name} to multi codec HLS manifest"
452
+ end
453
+
454
+ # Starting an encoding and monitoring it's status
455
+ enc.start!
456
+
457
+ while enc.status != 'FINISHED' && enc.status != 'ERROR'
458
+ puts "Encoding Status is #{enc.status}"
459
+ progress = enc.progress
460
+ if progress > 0
461
+ puts "Progress: #{enc.progress} %"
462
+ end
463
+ sleep 2
464
+ end
465
+ puts "Encoding finished with status #{enc.status}!"
466
+
467
+ # Now that the encoding is finished we can start writing the m3u8 Manifest
468
+ hls_manifests.each do |hls_manifest|
469
+
470
+ hls_manifest.start!
471
+
472
+ while hls_manifest.status != 'FINISHED' && hls_manifest.status != 'ERROR'
473
+ puts "HLS Manifest status is #{hls_manifest.status}"
474
+ progress = hls_manifest.progress
475
+ if progress > 0
476
+ puts "Progress: #{hls_manifest.progress} %"
477
+ end
478
+ sleep 2
479
+ end
480
+
481
+ puts "HLS Manifest generation #{hls_manifest.name} finished with status #{hls_manifest.status}"
482
+
483
+ end
484
+
485
+ # Begin DASH manifests generation
486
+ dash_manifests.each do |dash_manifest|
487
+
488
+ dash_manifest.start!
489
+
490
+ while dash_manifest.status != 'FINISHED' && dash_manifest.status != 'ERROR'
491
+ puts "DASH manifest generation status is #{dash_manifest.status}"
492
+ progress = dash_manifest.progress
493
+ if progress > 0
494
+ puts "Progress: #{dash_manifest.progress}"
495
+ end
496
+ sleep 2
497
+ end
498
+
499
+ puts "DASH Manifest generation #{dash_manifest.name} finished with status #{dash_manifest.status}"
500
+ end
501
+
502
+ puts 'All Manifests generated!'