bitmovin-ruby 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,205 +0,0 @@
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
- M3U8_NAME = "playlist.m3u8"
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
-
63
- # Let's also start the Manifest generation
64
- manifest = Bitmovin::Encoding::Manifests::HlsManifest.new({
65
- name: 'Test Ruby Manifest',
66
- description: "Test encoding with ruby",
67
- manifest_name: M3U8_NAME
68
- })
69
-
70
- manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
71
- output_id: s3_output.id,
72
- output_path: OUTPUT_PATH
73
- })
74
- manifest.save!
75
-
76
- create_audio!(enc, manifest, s3_input, s3_output)
77
-
78
- # Adding Video Streams to Encoding
79
- video_configs.each do |config|
80
- if (config[:name].start_with?("h264"))
81
- codec_config = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new(config)
82
- else
83
- codec_config = Bitmovin::Encoding::CodecConfigurations::H265Configuration.new(config)
84
- end
85
- codec_config.save!
86
- config = OpenStruct.new(config)
87
-
88
- str = enc.streams.build(name: codec_config.name)
89
- str.codec_configuration = codec_config
90
- str.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
91
- str.conditions = {
92
- type: "CONDITION",
93
- attribute: "HEIGHT",
94
- operator: "<=",
95
- value: codec_config.height
96
- }
97
- str.save!
98
-
99
- muxing = enc.muxings.fmp4.build(name: "#{codec_config.name} muxing", segment_length: 4)
100
- muxing.streams << str.id
101
- muxing.build_output({
102
- output_id: s3_output.id,
103
- output_path: File.join(OUTPUT_PATH, config.name),
104
- acl: [{
105
- permission: "PUBLIC_READ"
106
- }]
107
- })
108
- muxing.save!
109
- puts "Finished muxing #{muxing.name}"
110
-
111
- # Add the Stream to the Manifest too
112
- hls_stream = manifest.build_stream({
113
- audio: 'audio_group',
114
- closed_captions: 'NONE',
115
- segmentPath: config.name,
116
- encoding_id: enc.id,
117
- muxing_id: muxing.id,
118
- stream_id: str.id,
119
- #drm_id: aes_muxing.id,
120
- uri: config.name + '.m3u8'
121
- })
122
- hls_stream.save!
123
- end
124
-
125
- # Starting an encoding and monitoring it's status
126
- enc.start!
127
-
128
- while(enc.status != 'FINISHED')
129
- puts "Encoding Status is #{enc.status}"
130
- progress = enc.progress
131
- if (progress > 0)
132
- puts "Progress: #{enc.progress} %"
133
- end
134
- sleep 2
135
- end
136
- puts "Encoding finished!"
137
-
138
- # Now that the encoding is finished we can start writing the m3u8 Manifest
139
- manifest.start!
140
-
141
- while(manifest.status != 'FINISHED')
142
- puts "manifestoding Status is #{manifest.status}"
143
- progress = manifest.progress
144
- if (progress > 0)
145
- puts "Progress: #{manifest.progress} %"
146
- end
147
- sleep 2
148
- end
149
-
150
- BEGIN {
151
- # Begin is a hack to have this method available but define it at the end of the file
152
- def create_audio!(enc, manifest, s3_input, s3_output)
153
-
154
- # Create or load the Audio Config
155
- #audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.find("<EXISTING_AAC_CONFIG_ID>")
156
- audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.new({
157
- name: "AAC_PROFILE_128k",
158
- bitrate: 128000,
159
- rate: 48000
160
- })
161
- audio_config.save!
162
- #
163
- # Adding Audio Stream to Encoding
164
- stream_aac = enc.streams.build(name: 'audio stream')
165
- stream_aac.codec_configuration = audio_config
166
- stream_aac.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
167
- stream_aac.conditions = {
168
- type: "CONDITION",
169
- attribute: "INPUTSTREAM",
170
- operator: "==",
171
- value: "TRUE"
172
- }
173
- puts stream_aac.conditions.to_json
174
- stream_aac.save!
175
-
176
- # Audio Muxing
177
- audio_muxing = enc.muxings.fmp4.build(name: 'audio-muxing', segment_length: 4)
178
- audio_muxing.build_output({
179
- output_id: s3_output.id,
180
- output_path: File.join(OUTPUT_PATH, "audio/aac")
181
- })
182
- audio_muxing.build_output({
183
- output_id: s3_output.id,
184
- output_path: File.join(OUTPUT_PATH, "audio/aac"),
185
- acl: [{
186
- permission: "PUBLIC_READ"
187
- }]
188
- })
189
- audio_muxing.streams << stream_aac.id
190
- audio_muxing.save!
191
-
192
- # Adding Audio Stream to HLS Manifest
193
- audio_stream_medium = manifest.build_audio_medium({
194
- name: "HLS Audio Media",
195
- group_id: "audio_group",
196
- segment_path: "audio/aac",
197
- encoding_id: enc.id,
198
- stream_id: stream_aac.id,
199
- muxing_id: audio_muxing.id,
200
- language: "en",
201
- uri: "audio_media.m3u8"
202
- })
203
- audio_stream_medium.save!
204
- end
205
- }
@@ -1,221 +0,0 @@
1
- require 'bitmovin-ruby'
2
-
3
- # CONFIGURATION
4
- BITMOVIN_API_KEY = "YOUR API KEY HERE"
5
- AWS_ACCESS_KEY = "YOUR AWS_ACCESS_KEY"
6
- AWS_SECRET_KEY = "YOUR AWS_SECRET_KEY"
7
- BUCKET_NAME = "YOUR BUCKET NAME HERE"
8
- INPUT_FILE_PATH = "path/to/input/file.mp4"
9
- OUTPUT_PATH = "path/to/output"
10
- MPD_NAME = "manifest.mpd"
11
-
12
- OUTPUT_AWS_ACCESS_KEY = "YOUR AWS_ACCESS_KEY"
13
- OUTPUT_AWS_SECRET_KEY = "YOUR AWS_SECRET_KEY"
14
-
15
- Bitmovin.init(BITMOVIN_API_KEY)
16
-
17
-
18
- # This will create a Input Bucket you can reuse in future encodings
19
- # To get a list of all your S3Inputs do:
20
- # Bitmovin::Encoding::Inputs::S3Input.list
21
-
22
- s3_input = Bitmovin::Encoding::Inputs::S3Input.new({
23
- accessKey: AWS_ACCESS_KEY,
24
- secretKey: AWS_SECRET_KEY,
25
- bucketName: BUCKET_NAME
26
- }).save!
27
-
28
- # This will create a Output Bucket you can reuse in future encodings
29
- # To get a list of all your Output do:
30
- # Bitmovin::Encoding::Outputs::S3Output.list
31
- s3_output = Bitmovin::Encoding::Outputs::S3Output.new({
32
- accessKey: OUTPUT_AWS_ACCESS_KEY,
33
- secretKey: OUTPUT_AWS_SECRET_KEY,
34
- bucketName: BUCKET_NAME
35
- }).save!
36
-
37
-
38
- # Please note inputs/outputs are not individual files but rather the
39
- # Bucket you are reading/writing files to and they can be reused between encodings.
40
-
41
-
42
- # Codec Configurations are similar to Inputs/Outputs in that they are configured once
43
- # and can be reused for future encodings.
44
- codec_config_720_700 = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new({
45
- name: "H264 1280x720 700kb/s",
46
- profile: "MAIN",
47
- width: 1280,
48
- height: 720,
49
- bitrate: 700000
50
- })
51
- codec_config_720_700.save!
52
- codec_config_720_1500 = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new({
53
- name: "H264 1280x720 1500kb/s",
54
- profile: "MAIN",
55
- width: 1280,
56
- height: 720,
57
- bitrate: 1500000
58
- })
59
- codec_config_720_1500.save!
60
- codec_config_720_2400 = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new({
61
- name: "H264 1280x720 2400kb/s",
62
- profile: "MAIN",
63
- width: 1280,
64
- height: 720,
65
- bitrate: 2400000
66
- })
67
- codec_config_720_2400.save!
68
-
69
- audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.new({
70
- name: "AAC_PROFILE_128k",
71
- bitrate: 128000,
72
- rate: 48000
73
- })
74
- audio_config.save!
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
- # The actual instance of the encoding task you are about to start
83
- enc = Bitmovin::Encoding::Encodings::EncodingTask.new({
84
- name: "VOD Encoding Ruby",
85
- cloud_region: "AWS_AP_SOUTHEAST_1"
86
- })
87
- enc.save!
88
-
89
- # Stream Configuration
90
-
91
- stream_720_700 = enc.streams.build(name: 'H264 1280x720 700kb/s')
92
- stream_720_700.codec_configuration = codec_config_720_700
93
- stream_720_700.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
94
- stream_720_700.save!
95
-
96
- stream_720_1500 = enc.streams.build(name: 'H264 1280x720 1500/s')
97
- stream_720_1500.codec_configuration = codec_config_720_1500
98
- stream_720_1500.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
99
- stream_720_1500.save!
100
-
101
- stream_720_2400 = enc.streams.build(name: 'H264 1280x720 2400/s')
102
- stream_720_2400.codec_configuration = codec_config_720_2400
103
- stream_720_2400.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
104
- stream_720_2400.save!
105
-
106
- stream_aac = enc.streams.build(name: 'audio stream')
107
- stream_aac.codec_configuration = audio_config
108
- stream_aac.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
109
- stream_aac.save!
110
-
111
- # Muxing Configuration
112
-
113
- fmp4_muxing_720_700 = enc.muxings.fmp4.build(name: 'H264 1280x720 700kb/s', segment_length: 4)
114
- fmp4_muxing_720_700.build_output({
115
- output_id: s3_output.id,
116
- output_path: File.join(OUTPUT_PATH, "video/720_700")
117
- })
118
- fmp4_muxing_720_700.streams << stream_720_700.id
119
- fmp4_muxing_720_700.save!
120
-
121
- fmp4_muxing_720_1500 = enc.muxings.fmp4.build(name: 'H264 1280x720 1500kb/s', segment_length: 4)
122
- fmp4_muxing_720_1500.build_output({
123
- output_id: s3_output.id,
124
- output_path: File.join(OUTPUT_PATH, "video/720_1500")
125
- })
126
- fmp4_muxing_720_1500.streams << stream_720_1500.id
127
- fmp4_muxing_720_1500.save!
128
-
129
- fmp4_muxing_720_2400 = enc.muxings.fmp4.build(name: 'H264 1280x720 2400kb/s', segment_length: 4)
130
- fmp4_muxing_720_2400.build_output({
131
- output_id: s3_output.id,
132
- output_path: File.join(OUTPUT_PATH, "video/720_2400")
133
- })
134
- fmp4_muxing_720_2400.streams << stream_720_2400.id
135
- fmp4_muxing_720_2400.save!
136
-
137
- audio_muxing = enc.muxings.fmp4.build(name: 'audio-muxing', segment_length: 4)
138
- audio_muxing.build_output({
139
- output_id: s3_output.id,
140
- output_path: File.join(OUTPUT_PATH, "audio/aac")
141
- })
142
- audio_muxing.streams << stream_aac.id
143
- audio_muxing.save!
144
-
145
-
146
- # Starting an encoding and monitoring it's status
147
- enc.start!
148
-
149
- while(enc.status != 'FINISHED')
150
- puts "Encoding Status is #{enc.status}"
151
- progress = enc.progress
152
- if (progress > 0)
153
- puts "Progress: #{enc.progress} %"
154
- end
155
- sleep 2
156
- end
157
- puts "Encoding finished!"
158
-
159
-
160
-
161
- # Generating a DASH Manifest
162
-
163
- puts "Starting Manifest generation"
164
- manifest = Bitmovin::Encoding::Manifests::DashManifest.new({
165
- name: 'Test Ruby Manifest',
166
- description: "Test encoding with ruby",
167
- manifest_name: MPD_NAME
168
- })
169
-
170
- manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
171
- output_id: s3_output.id,
172
- output_path: OUTPUT_PATH
173
- })
174
- manifest.save!
175
-
176
- period = manifest.build_period()
177
- period.save!
178
-
179
- video_adaptationset = period.build_video_adaptationset()
180
- video_adaptationset.save!
181
-
182
- audio_adaptationset = period.build_audio_adaptationset({ lang: 'en' })
183
- audio_adaptationset.save!
184
-
185
- video_adaptationset.build_fmp4_representation({
186
- encoding_id: enc.id,
187
- muxing_id: fmp4_muxing_720_2400.id,
188
- type: 'TEMPLATE',
189
- segment_path: "video/720_2400"
190
- }).save!
191
- video_adaptationset.build_fmp4_representation({
192
- encoding_id: enc.id,
193
- muxing_id: fmp4_muxing_720_1500.id,
194
- type: 'TEMPLATE',
195
- segment_path: "video/720_1500"
196
- }).save!
197
- video_adaptationset.build_fmp4_representation({
198
- encoding_id: enc.id,
199
- muxing_id: fmp4_muxing_720_700.id,
200
- type: 'TEMPLATE',
201
- segment_path: "video/720_700"
202
- }).save!
203
-
204
- audio_adaptationset.build_fmp4_representation({
205
- encoding_id: enc.id,
206
- muxing_id: audio_muxing.id,
207
- name: '1080p',
208
- type: 'TEMPLATE',
209
- segment_path: "audio/aac"
210
- }).save!
211
-
212
- manifest.start!
213
-
214
- while(manifest.status != 'FINISHED')
215
- puts "manifestoding Status is #{manifest.status}"
216
- progress = manifest.progress
217
- if (progress > 0)
218
- puts "Progress: #{manifest.progress} %"
219
- end
220
- sleep 2
221
- end
@@ -1,216 +0,0 @@
1
- # CONFIGURATION
2
- BITMOVIN_API_KEY = 'YOUR API KEY HERE'
3
-
4
- HTTP_INPUT_HOST = 'your.host.com'
5
- HTTP_INPUT_FILE_PATH = '/path/to/your/input/file.mkv'
6
-
7
- OUTPUT_AWS_ACCESS_KEY = 'YOUR AWS_ACCESS_KEY'
8
- OUTPUT_AWS_SECRET_KEY = 'YOUR AWS_SECRET_KEY'
9
-
10
- BUCKET_NAME = 'YOUR BUCKET NAME HERE'
11
- OUTPUT_PATH = 'path/to/output'
12
- MPD_NAME = 'manifest.mpd'
13
-
14
- # Please refer to our API spec to get available cloud regions
15
- # https://bitmovin.com/encoding-documentation/bitmovin-api/#/reference/encoding/encodings/create-encoding
16
- ENCODING_CLOUD_REGION = 'GOOGLE_EUROPE_WEST_1'
17
-
18
- Bitmovin.init(BITMOVIN_API_KEY)
19
-
20
- # This will create a http input
21
- # To get a list of all your HTTP outputs do:
22
- # Bitmovin::Encoding::Outputs::HttpOutput.list
23
- http_input = Bitmovin::Encoding::Inputs::HttpInput.new({
24
- host: HTTP_INPUT_HOST
25
- }).save!
26
-
27
- # For reuse set http_input_id = '<YOUR HTTP INPUT ID>' and omit creation
28
- http_input_id = http_input.id
29
-
30
- # This will create a Output Bucket you can reuse in future encodings
31
- # To get a list of all your Output do:
32
- # Bitmovin::Encoding::Outputs::S3Output.list
33
- s3_output = Bitmovin::Encoding::Outputs::S3Output.new({
34
- accessKey: OUTPUT_AWS_ACCESS_KEY,
35
- secretKey: OUTPUT_AWS_SECRET_KEY,
36
- bucketName: BUCKET_NAME
37
- }).save!
38
-
39
- # For reuse set s3_output_id = '<YOUR S3 OUTPUT ID>' and omit creation
40
- s3_output_id = s3_output.id
41
-
42
- # Codec Configurations are similar to Inputs/Outputs in that they are configured once
43
- # and can be reused for future encodings.
44
- codec_config_720_700 = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new({
45
- name: 'H264 1280x720 700kb/s',
46
- profile: 'MAIN',
47
- width: 1280,
48
- height: 720,
49
- bitrate: 700000
50
- })
51
- codec_config_720_700.save!
52
- codec_config_720_1500 = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new({
53
- name: 'H264 1280x720 1500kb/s',
54
- profile: 'MAIN',
55
- width: 1280,
56
- height: 720,
57
- bitrate: 1500000
58
- })
59
- codec_config_720_1500.save!
60
- codec_config_720_2400 = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new({
61
- name: 'H264 1280x720 2400kb/s',
62
- profile: 'MAIN',
63
- width: 1280,
64
- height: 720,
65
- bitrate: 2400000
66
- })
67
- codec_config_720_2400.save!
68
-
69
- audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.new({
70
- name: 'AAC_PROFILE_128k',
71
- bitrate: 128000,
72
- rate: 48000
73
- })
74
- audio_config.save!
75
-
76
-
77
- # The actual instance of the encoding task you are about to start
78
- enc = Bitmovin::Encoding::Encodings::EncodingTask.new({
79
- name: 'VOD Encoding Ruby',
80
- cloud_region: ENCODING_CLOUD_REGION
81
- })
82
- enc.save!
83
-
84
- # Stream Configuration
85
-
86
- stream_720_700 = enc.streams.build(name: 'H264 1280x720 700kb/s')
87
- stream_720_700.codec_configuration = codec_config_720_700
88
- stream_720_700.build_input_stream(input_path: INPUT_FILE_PATH, input_id: http_input_id, selection_mode: 'AUTO')
89
- stream_720_700.save!
90
-
91
- stream_720_1500 = enc.streams.build(name: 'H264 1280x720 1500/s')
92
- stream_720_1500.codec_configuration = codec_config_720_1500
93
- stream_720_1500.build_input_stream(input_path: INPUT_FILE_PATH, input_id: http_input_id, selection_mode: 'AUTO')
94
- stream_720_1500.save!
95
-
96
- stream_720_2400 = enc.streams.build(name: 'H264 1280x720 2400/s')
97
- stream_720_2400.codec_configuration = codec_config_720_2400
98
- stream_720_2400.build_input_stream(input_path: INPUT_FILE_PATH, input_id: http_input_id, selection_mode: 'AUTO')
99
- stream_720_2400.save!
100
-
101
- stream_aac = enc.streams.build(name: 'audio stream')
102
- stream_aac.codec_configuration = audio_config
103
- stream_aac.build_input_stream(input_path: INPUT_FILE_PATH, input_id: http_input_id, selection_mode: 'AUTO')
104
- stream_aac.save!
105
-
106
- # Muxing Configuration
107
-
108
- fmp4_muxing_720_700 = enc.muxings.fmp4.build(name: 'H264 1280x720 700kb/s', segment_length: 4)
109
- fmp4_muxing_720_700.build_output({
110
- output_id: s3_output_id,
111
- output_path: File.join(OUTPUT_PATH, 'video/720_700')
112
- })
113
- fmp4_muxing_720_700.streams << stream_720_700.id
114
- fmp4_muxing_720_700.save!
115
-
116
- fmp4_muxing_720_1500 = enc.muxings.fmp4.build(name: 'H264 1280x720 1500kb/s', segment_length: 4)
117
- fmp4_muxing_720_1500.build_output({
118
- output_id: s3_output_id,
119
- output_path: File.join(OUTPUT_PATH, 'video/720_1500')
120
- })
121
- fmp4_muxing_720_1500.streams << stream_720_1500.id
122
- fmp4_muxing_720_1500.save!
123
-
124
- fmp4_muxing_720_2400 = enc.muxings.fmp4.build(name: 'H264 1280x720 2400kb/s', segment_length: 4)
125
- fmp4_muxing_720_2400.build_output({
126
- output_id: s3_output_id,
127
- output_path: File.join(OUTPUT_PATH, 'video/720_2400')
128
- })
129
- fmp4_muxing_720_2400.streams << stream_720_2400.id
130
- fmp4_muxing_720_2400.save!
131
-
132
- audio_muxing = enc.muxings.fmp4.build(name: 'audio-muxing', segment_length: 4)
133
- audio_muxing.build_output({
134
- output_id: s3_output_id,
135
- output_path: File.join(OUTPUT_PATH, 'audio/aac')
136
- })
137
- audio_muxing.streams << stream_aac.id
138
- audio_muxing.save!
139
-
140
-
141
- # Starting an encoding and monitoring it's status
142
- enc.start!
143
-
144
- while enc.status != 'FINISHED' && enc.status != 'ERROR'
145
- puts "Encoding Status is #{enc.status}"
146
- progress = enc.progress
147
- if progress > 0
148
- puts "Progress: #{enc.progress} %"
149
- end
150
- sleep 2
151
- end
152
- puts "Encoding finished with status #{enc.status}!"
153
-
154
-
155
- # Generating a DASH Manifest
156
- puts 'Starting Manifest generation'
157
- manifest = Bitmovin::Encoding::Manifests::DashManifest.new({
158
- name: 'Test Ruby Manifest',
159
- description: 'Test encoding with ruby',
160
- manifest_name: MPD_NAME
161
- })
162
-
163
- manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
164
- output_id: s3_output_id,
165
- output_path: OUTPUT_PATH
166
- })
167
- manifest.save!
168
-
169
- period = manifest.build_period()
170
- period.save!
171
-
172
- video_adaptationset = period.build_video_adaptationset()
173
- video_adaptationset.save!
174
-
175
- audio_adaptationset = period.build_audio_adaptationset({lang: 'en'})
176
- audio_adaptationset.save!
177
-
178
- video_adaptationset.build_fmp4_representation({
179
- encoding_id: enc.id,
180
- muxing_id: fmp4_muxing_720_2400.id,
181
- type: 'TEMPLATE',
182
- segment_path: 'video/720_2400'
183
- }).save!
184
- video_adaptationset.build_fmp4_representation({
185
- encoding_id: enc.id,
186
- muxing_id: fmp4_muxing_720_1500.id,
187
- type: 'TEMPLATE',
188
- segment_path: 'video/720_1500'
189
- }).save!
190
- video_adaptationset.build_fmp4_representation({
191
- encoding_id: enc.id,
192
- muxing_id: fmp4_muxing_720_700.id,
193
- type: 'TEMPLATE',
194
- segment_path: 'video/720_700'
195
- }).save!
196
-
197
- audio_adaptationset.build_fmp4_representation({
198
- encoding_id: enc.id,
199
- muxing_id: audio_muxing.id,
200
- name: 'Audio representation',
201
- type: 'TEMPLATE',
202
- segment_path: 'audio/aac'
203
- }).save!
204
-
205
- manifest.start!
206
-
207
- while manifest.status != 'FINISHED' && manifest.status != 'ERROR'
208
- puts "Manifest Status is #{manifest.status}"
209
- progress = manifest.progress
210
- if progress > 0
211
- puts "Progress: #{manifest.progress} %"
212
- end
213
- sleep 2
214
- end
215
-
216
- puts "Manifest generation finished with status #{manifest.status}!"