bitmovin-ruby 0.4.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +1 -1
  5. data/Gemfile.lock +49 -49
  6. data/README.md +1 -1
  7. data/bitmovin-ruby.gemspec +3 -3
  8. data/lib/bitmovin-ruby.rb +2 -2
  9. data/lib/bitmovin/client.rb +8 -6
  10. data/lib/bitmovin/encoding/encodings.rb +4 -1
  11. data/lib/bitmovin/encoding/encodings/input_streams/ingest.rb +44 -0
  12. data/lib/bitmovin/encoding/encodings/input_streams/trimming/time_based.rb +48 -0
  13. data/lib/bitmovin/encoding/encodings/muxings/drms/drm_muxing_resource.rb +1 -1
  14. data/lib/bitmovin/encoding/encodings/muxings/mp4_muxing.rb +1 -0
  15. data/lib/bitmovin/encoding/encodings/muxings/muxing_resource.rb +1 -1
  16. data/lib/bitmovin/encoding/encodings/sprites/sprite.rb +76 -0
  17. data/lib/bitmovin/encoding/encodings/stream.rb +16 -2
  18. data/lib/bitmovin/encoding/encodings/stream_input.rb +5 -3
  19. data/lib/bitmovin/encoding/encodings/thumbnails/thumbnail.rb +71 -0
  20. data/lib/bitmovin/encoding/manifests/audio_adaptation_set.rb +1 -2
  21. data/lib/bitmovin/encoding/manifests/fmp4_representation.rb +1 -2
  22. data/lib/bitmovin/encoding/manifests/hls_audio_media.rb +16 -11
  23. data/lib/bitmovin/encoding/manifests/hls_variant_stream.rb +1 -1
  24. data/lib/bitmovin/encoding/manifests/hls_variant_stream_list.rb +1 -2
  25. data/lib/bitmovin/encoding/manifests/manifest_resource.rb +1 -1
  26. data/lib/bitmovin/encoding/manifests/period.rb +1 -1
  27. data/lib/bitmovin/encoding/manifests/video_adaptation_set.rb +1 -2
  28. data/lib/bitmovin/encoding/stream_output.rb +1 -0
  29. data/lib/bitmovin/helpers.rb +5 -1
  30. data/lib/bitmovin/resource.rb +19 -13
  31. data/lib/bitmovin/version.rb +1 -1
  32. data/lib/bitmovin/webhooks.rb +1 -0
  33. data/lib/bitmovin/webhooks/encoding_error_webhook.rb +14 -0
  34. data/lib/bitmovin/webhooks/encoding_finished_webhook.rb +9 -0
  35. metadata +17 -17
  36. data/examples/create_encoding_finished_webhook.rb +0 -21
  37. data/examples/dash_hls_mp4_encoding_with_manifests.rb +0 -502
  38. data/examples/hls_multi_codec.rb +0 -205
  39. data/examples/simple_dash.rb +0 -221
  40. data/examples/simple_dash_with_http_input.rb +0 -216
  41. data/examples/simple_hls_with_aes128.rb +0 -197
@@ -1,197 +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
- INPUT_FILE_PATH = "encoding/awolnation.mkv"
9
- OUTPUT_PATH = "/encoding_test/bitmovin-ruby/#{Time.now.strftime("%v-%H-%M")}/"
10
- M3U8_NAME = "playlist.m3u8"
11
-
12
- DRM_AES_KEY = "759678DC403B3CB84125E8E0F0824CD6" # Change this to something else
13
- DRM_AES_IV = "196E6EB871BBC09191A3995318406198"
14
-
15
- Bitmovin.init(BITMOVIN_API_KEY)
16
-
17
- # This will create a Input Bucket you can reuse in future encodings
18
- # To get a list of all your S3Inputs do:
19
- # Bitmovin::Encoding::Inputs::S3Input.list
20
- s3_input = Bitmovin::Encoding::Inputs::S3Input.find(S3_INPUT_ID)
21
-
22
- # This will create a Output Bucket you can reuse in future encodings
23
- # To get a list of all your Output do:
24
- # Bitmovin::Encoding::Outputs::S3Output.list
25
- s3_output = Bitmovin::Encoding::Outputs::S3Output.find(S3_OUTPUT_ID)
26
-
27
- # Please note inputs/outputs are not individual files but rather the
28
- # Bucket you are reading/writing files to and they can be reused between encodings.
29
-
30
-
31
- # This hash contains the H264 Codec Configurations we want to create
32
- # Codec Configurations are similar to Inputs/Outputs in that they are configured once
33
- # and can be reused for future encodings.
34
- video_configs = [
35
- { name: "h264_720p_700",
36
- profile: "MAIN",
37
- height: 720,
38
- bitrate: 700000
39
- }, {
40
- name: "h264_540p_500",
41
- profile: "MAIN",
42
- height: 540,
43
- bitrate: 500000
44
- }
45
- ]
46
-
47
- # The actual instance of the encoding task you are about to start
48
- enc = Bitmovin::Encoding::Encodings::EncodingTask.new({
49
- name: "VOD Encoding HLS AES128 Ruby"
50
- })
51
- enc.save!
52
-
53
-
54
- # Let's also start the Manifest generation
55
- manifest = Bitmovin::Encoding::Manifests::HlsManifest.new({
56
- name: 'Test Ruby Manifest',
57
- description: "Test encoding with ruby",
58
- manifest_name: M3U8_NAME
59
- })
60
-
61
- manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
62
- output_id: s3_output.id,
63
- output_path: OUTPUT_PATH
64
- })
65
- manifest.save!
66
-
67
- create_audio!(enc, manifest, s3_input, s3_output)
68
-
69
- # Adding Video Streams to Encoding
70
- video_configs.each do |config|
71
- h264_config = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new(config)
72
- h264_config.save!
73
- config = OpenStruct.new(config)
74
-
75
- str = enc.streams.build(name: h264_config.name)
76
- str.codec_configuration = h264_config
77
- str.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
78
- str.save!
79
-
80
- muxing = enc.muxings.ts.build(name: "#{h264_config.name} muxing", segment_length: 4)
81
- muxing.streams << str.id
82
- muxing.save!
83
-
84
- aes_muxing = muxing.drms.aes.build({
85
- key: DRM_AES_KEY,
86
- iv: DRM_AES_IV,
87
- method: 'AES_128',
88
- name: "AES DRM for #{muxing.name}"
89
- })
90
- aes_muxing.build_output({
91
- output_id: s3_output.id,
92
- output_path: File.join(OUTPUT_PATH, config.name),
93
- acl: [{
94
- permission: "PUBLIC_READ"
95
- }]
96
- })
97
- aes_muxing.save!
98
- puts "Finished DRM Muxing"
99
-
100
- # Add the Stream to the Manifest too
101
- hls_stream = manifest.build_stream({
102
- audio: 'audio_group',
103
- closed_captions: 'NONE',
104
- segmentPath: config.name,
105
- encoding_id: enc.id,
106
- muxing_id: muxing.id,
107
- stream_id: str.id,
108
- drm_id: aes_muxing.id,
109
- uri: config.name + '.m3u8'
110
- })
111
- hls_stream.save!
112
- end
113
-
114
- # Starting an encoding and monitoring it's status
115
- enc.start!
116
-
117
- while(enc.status != 'FINISHED')
118
- puts "Encoding Status is #{enc.status}"
119
- progress = enc.progress
120
- if (progress > 0)
121
- puts "Progress: #{enc.progress} %"
122
- end
123
- sleep 2
124
- end
125
- puts "Encoding finished!"
126
-
127
- # Now that the encoding is finished we can start writing the m3u8 Manifest
128
- manifest.start!
129
-
130
- while(manifest.status != 'FINISHED')
131
- puts "manifestoding Status is #{manifest.status}"
132
- progress = manifest.progress
133
- if (progress > 0)
134
- puts "Progress: #{manifest.progress} %"
135
- end
136
- sleep 2
137
- end
138
-
139
- BEGIN {
140
- # Begin is a hack to have this method available but define it at the end of the file
141
- def create_audio!(enc, manifest, s3_input, s3_output)
142
-
143
- # Create or load the Audio Config
144
- #audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.find("<EXISTING_AAC_CONFIG_ID>")
145
- audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.new({
146
- name: "AAC_PROFILE_128k",
147
- bitrate: 128000,
148
- rate: 48000
149
- })
150
- audio_config.save!
151
- #
152
- # Adding Audio Stream to Encoding
153
- stream_aac = enc.streams.build(name: 'audio stream')
154
- stream_aac.codec_configuration = audio_config
155
- stream_aac.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
156
- stream_aac.save!
157
-
158
- # Audio Muxing
159
- audio_muxing = enc.muxings.ts.build(name: 'audio-muxing', segment_length: 4)
160
- audio_muxing.build_output({
161
- output_id: s3_output.id,
162
- output_path: File.join(OUTPUT_PATH, "audio/aac")
163
- })
164
- audio_muxing.streams << stream_aac.id
165
- audio_muxing.save!
166
-
167
- aes_audio_muxing = audio_muxing.drms.aes.build({
168
- key: DRM_AES_KEY,
169
- iv: DRM_AES_IV,
170
- method: 'AES_128',
171
- name: "AES DRM for Audio"
172
- })
173
- aes_audio_muxing.build_output({
174
- output_id: s3_output.id,
175
- output_path: File.join(OUTPUT_PATH, "audio/aac"),
176
- acl: [{
177
- permission: "PUBLIC_READ"
178
- }]
179
- })
180
- aes_audio_muxing.save!
181
- puts "Finished DRM Muxing"
182
-
183
- # Adding Audio Stream to HLS Manifest
184
- audio_stream_medium = manifest.build_audio_medium({
185
- name: "HLS Audio Media",
186
- group_id: "audio_group",
187
- segment_path: "audio/aac",
188
- encoding_id: enc.id,
189
- stream_id: stream_aac.id,
190
- muxing_id: audio_muxing.id,
191
- drm_id: aes_audio_muxing.id,
192
- language: "en",
193
- uri: "audio_media.m3u8"
194
- })
195
- audio_stream_medium.save!
196
- end
197
- }