bitmovin-ruby 0.1.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.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +13 -0
  6. data/Gemfile.lock +125 -0
  7. data/Guardfile +70 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +44 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/bitmovin-ruby.gemspec +31 -0
  14. data/examples/simple_dash.rb +191 -0
  15. data/lib/bitmovin/bitmovin_error.rb +7 -0
  16. data/lib/bitmovin/child_collection.rb +41 -0
  17. data/lib/bitmovin/client.rb +35 -0
  18. data/lib/bitmovin/configuration_resource.rb +4 -0
  19. data/lib/bitmovin/encoding/codec_configurations/aac_configuration.rb +7 -0
  20. data/lib/bitmovin/encoding/codec_configurations/h264_configuration.rb +9 -0
  21. data/lib/bitmovin/encoding/codec_configurations/h265_configuration.rb +8 -0
  22. data/lib/bitmovin/encoding/codec_configurations/vp9_configuration.rb +8 -0
  23. data/lib/bitmovin/encoding/codec_configurations.rb +23 -0
  24. data/lib/bitmovin/encoding/encodings/encoding_task.rb +67 -0
  25. data/lib/bitmovin/encoding/encodings/list.rb +39 -0
  26. data/lib/bitmovin/encoding/encodings/muxing_list.rb +19 -0
  27. data/lib/bitmovin/encoding/encodings/muxings/fmp4_muxing.rb +5 -0
  28. data/lib/bitmovin/encoding/encodings/muxings/fmp4_muxing_list.rb +5 -0
  29. data/lib/bitmovin/encoding/encodings/muxings/mp4_muxing.rb +4 -0
  30. data/lib/bitmovin/encoding/encodings/muxings/mp4_muxing_list.rb +5 -0
  31. data/lib/bitmovin/encoding/encodings/muxings/muxing_resource.rb +56 -0
  32. data/lib/bitmovin/encoding/encodings/muxings/ts_muxing.rb +5 -0
  33. data/lib/bitmovin/encoding/encodings/muxings/ts_muxing_list.rb +5 -0
  34. data/lib/bitmovin/encoding/encodings/muxings/webm_muxing.rb +5 -0
  35. data/lib/bitmovin/encoding/encodings/muxings/webm_muxing_list.rb +5 -0
  36. data/lib/bitmovin/encoding/encodings/stream.rb +102 -0
  37. data/lib/bitmovin/encoding/encodings/stream_input.rb +51 -0
  38. data/lib/bitmovin/encoding/encodings/stream_list.rb +5 -0
  39. data/lib/bitmovin/encoding/encodings.rb +24 -0
  40. data/lib/bitmovin/encoding/inputs/analysis.rb +27 -0
  41. data/lib/bitmovin/encoding/inputs/analysis_task.rb +73 -0
  42. data/lib/bitmovin/encoding/inputs/aspera_input.rb +7 -0
  43. data/lib/bitmovin/encoding/inputs/azure_input.rb +8 -0
  44. data/lib/bitmovin/encoding/inputs/ftp_input.rb +7 -0
  45. data/lib/bitmovin/encoding/inputs/gcs_input.rb +7 -0
  46. data/lib/bitmovin/encoding/inputs/generic_s3_input.rb +7 -0
  47. data/lib/bitmovin/encoding/inputs/http_input.rb +7 -0
  48. data/lib/bitmovin/encoding/inputs/https_input.rb +7 -0
  49. data/lib/bitmovin/encoding/inputs/rtmp_input.rb +6 -0
  50. data/lib/bitmovin/encoding/inputs/s3_input.rb +7 -0
  51. data/lib/bitmovin/encoding/inputs/sftp_input.rb +7 -0
  52. data/lib/bitmovin/encoding/inputs.rb +27 -0
  53. data/lib/bitmovin/encoding/manifests/audio_adaptation_set.rb +22 -0
  54. data/lib/bitmovin/encoding/manifests/dash_manifest.rb +56 -0
  55. data/lib/bitmovin/encoding/manifests/dash_representations.rb +14 -0
  56. data/lib/bitmovin/encoding/manifests/fmp4_representation.rb +18 -0
  57. data/lib/bitmovin/encoding/manifests/hls_manifest.rb +7 -0
  58. data/lib/bitmovin/encoding/manifests/manifest_resource.rb +16 -0
  59. data/lib/bitmovin/encoding/manifests/period.rb +17 -0
  60. data/lib/bitmovin/encoding/manifests/video_adaptation.rb +8 -0
  61. data/lib/bitmovin/encoding/manifests/video_adaptation_set.rb +22 -0
  62. data/lib/bitmovin/encoding/manifests.rb +23 -0
  63. data/lib/bitmovin/encoding/outputs/gcs_output.rb +6 -0
  64. data/lib/bitmovin/encoding/outputs/s3_output.rb +6 -0
  65. data/lib/bitmovin/encoding/outputs.rb +17 -0
  66. data/lib/bitmovin/encoding/stream_output.rb +44 -0
  67. data/lib/bitmovin/encoding.rb +10 -0
  68. data/lib/bitmovin/helpers.rb +55 -0
  69. data/lib/bitmovin/input_resource.rb +16 -0
  70. data/lib/bitmovin/resource.rb +86 -0
  71. data/lib/bitmovin/version.rb +3 -0
  72. data/lib/bitmovin.rb +30 -0
  73. metadata +225 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a9542ed34e8f37af522159943cb5f9b19d5b849c
4
+ data.tar.gz: 787d1f252de6d12ce4ce0b980dd916cb7d496fca
5
+ SHA512:
6
+ metadata.gz: 802d001e012d4d12dd4d5d878ab3e7a27509a191dbce5db744d8e9e2bc09809a6f3aa248729e4a76130b7796f5f58f66839fb7f3320e31f35ad378aaf165dc94
7
+ data.tar.gz: 90b0013c8dea19e9761209bdb111c9088e6e6daf98c954eff7ab8108cf1a2da25cf1d4317c5bd3b9bccfc200327be3f72b63005a3fdf7c6adf4c8898dc3503d5
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ test.rb
10
+ test-manifest.rb
11
+ test_encoding.rb
12
+ delete.rb
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.13.6
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'guard-rspec', require: false
5
+ gem 'webmock'
6
+ gem 'pry'
7
+ gem 'simplecov'
8
+ gem 'codecov', :require => false, :group => :test
9
+ gem 'rspec-collection_matchers'
10
+ end
11
+
12
+ # Specify your gem's dependencies in bitmovin-ruby.gemspec
13
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,125 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bitmovin-ruby (0.1.0)
5
+ activesupport (~> 5.0.2)
6
+ faraday (~> 0.11.0)
7
+ faraday_middleware (~> 0.11.0)
8
+ httpclient (~> 2.8.3)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (5.0.2)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (~> 0.7)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ addressable (2.5.0)
19
+ public_suffix (~> 2.0, >= 2.0.2)
20
+ codecov (0.1.10)
21
+ json
22
+ simplecov
23
+ url
24
+ coderay (1.1.1)
25
+ concurrent-ruby (1.0.5)
26
+ crack (0.4.3)
27
+ safe_yaml (~> 1.0.0)
28
+ diff-lcs (1.3)
29
+ docile (1.1.5)
30
+ faraday (0.11.0)
31
+ multipart-post (>= 1.2, < 3)
32
+ faraday_middleware (0.11.0.1)
33
+ faraday (>= 0.7.4, < 1.0)
34
+ ffi (1.9.18)
35
+ formatador (0.2.5)
36
+ guard (2.14.1)
37
+ formatador (>= 0.2.4)
38
+ listen (>= 2.7, < 4.0)
39
+ lumberjack (~> 1.0)
40
+ nenv (~> 0.1)
41
+ notiffany (~> 0.0)
42
+ pry (>= 0.9.12)
43
+ shellany (~> 0.0)
44
+ thor (>= 0.18.1)
45
+ guard-compat (1.2.1)
46
+ guard-rspec (4.7.3)
47
+ guard (~> 2.1)
48
+ guard-compat (~> 1.1)
49
+ rspec (>= 2.99.0, < 4.0)
50
+ hashdiff (0.3.2)
51
+ httpclient (2.8.3)
52
+ i18n (0.8.1)
53
+ json (2.0.3)
54
+ listen (3.1.5)
55
+ rb-fsevent (~> 0.9, >= 0.9.4)
56
+ rb-inotify (~> 0.9, >= 0.9.7)
57
+ ruby_dep (~> 1.2)
58
+ lumberjack (1.0.11)
59
+ method_source (0.8.2)
60
+ minitest (5.10.1)
61
+ multipart-post (2.0.0)
62
+ nenv (0.3.0)
63
+ notiffany (0.1.1)
64
+ nenv (~> 0.1)
65
+ shellany (~> 0.0)
66
+ pry (0.10.4)
67
+ coderay (~> 1.1.0)
68
+ method_source (~> 0.8.1)
69
+ slop (~> 3.4)
70
+ public_suffix (2.0.5)
71
+ rake (10.5.0)
72
+ rb-fsevent (0.9.8)
73
+ rb-inotify (0.9.8)
74
+ ffi (>= 0.5.0)
75
+ rspec (3.5.0)
76
+ rspec-core (~> 3.5.0)
77
+ rspec-expectations (~> 3.5.0)
78
+ rspec-mocks (~> 3.5.0)
79
+ rspec-collection_matchers (1.1.3)
80
+ rspec-expectations (>= 2.99.0.beta1)
81
+ rspec-core (3.5.4)
82
+ rspec-support (~> 3.5.0)
83
+ rspec-expectations (3.5.0)
84
+ diff-lcs (>= 1.2.0, < 2.0)
85
+ rspec-support (~> 3.5.0)
86
+ rspec-mocks (3.5.0)
87
+ diff-lcs (>= 1.2.0, < 2.0)
88
+ rspec-support (~> 3.5.0)
89
+ rspec-support (3.5.0)
90
+ ruby_dep (1.5.0)
91
+ safe_yaml (1.0.4)
92
+ shellany (0.0.1)
93
+ simplecov (0.13.0)
94
+ docile (~> 1.1.0)
95
+ json (>= 1.8, < 3)
96
+ simplecov-html (~> 0.10.0)
97
+ simplecov-html (0.10.0)
98
+ slop (3.6.0)
99
+ thor (0.19.4)
100
+ thread_safe (0.3.6)
101
+ tzinfo (1.2.2)
102
+ thread_safe (~> 0.1)
103
+ url (0.3.2)
104
+ webmock (2.3.2)
105
+ addressable (>= 2.3.6)
106
+ crack (>= 0.3.2)
107
+ hashdiff
108
+
109
+ PLATFORMS
110
+ ruby
111
+
112
+ DEPENDENCIES
113
+ bitmovin-ruby!
114
+ bundler (~> 1.13)
115
+ codecov
116
+ guard-rspec
117
+ pry
118
+ rake (~> 10.0)
119
+ rspec (~> 3.0)
120
+ rspec-collection_matchers
121
+ simplecov
122
+ webmock
123
+
124
+ BUNDLED WITH
125
+ 1.14.6
data/Guardfile ADDED
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.call("routing/#{m[1]}_routing"),
51
+ rspec.spec.call("controllers/#{m[1]}_controller"),
52
+ rspec.spec.call("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Bitmovin Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Bitmovin::Ruby API Client
2
+ [![codecov](https://codecov.io/gh/bitmovin/bitmovin-ruby/branch/develop/graph/badge.svg)](https://codecov.io/gh/bitmovin/bitmovin-ruby)
3
+ [![Build Status](https://travis-ci.org/bitmovin/bitmovin-ruby.svg?branch=develop)](https://travis-ci.org/bitmovin/bitmovin-ruby)
4
+
5
+ Bitmovin::Ruby API-Client which enables you to seamlessly integrate the [Bitmovin API](https://bitmovin.com/video-infrastructure-service-bitmovin-api/) into your projects.
6
+ Using this API client requires an active account. [Sign up for a Bitmovin API key](https://bitmovin.com/bitmovins-video-api/).
7
+
8
+ The full [Bitmovin API reference](https://bitmovin.com/encoding-documentation/bitmovin-api/) can be found on our website.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'bitmovin-ruby'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install bitmovin-ruby
25
+
26
+ ## Usage
27
+
28
+ TODO: Write usage instructions here
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bitmovin/bitmovin-ruby.
39
+
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
44
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bitmovin/ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bitmovin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bitmovin-ruby"
8
+ spec.version = Bitmovin::VERSION
9
+ spec.authors = ["Daniel Hoelbling-Inzko"]
10
+ spec.email = ["daniel.hoelbling-inzko@bitmovin.com"]
11
+
12
+ spec.summary = %q{Api Client for the Bitmovin API}
13
+ spec.description = %q{Provides full access to the Bitmovin API (http://https://bitmovin.com/encoding-documentation/bitmovin-api/)}
14
+ spec.homepage = "https://github.com/bitmovin/bitmovin-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "faraday", "~> 0.11.0"
25
+ spec.add_dependency "httpclient", "~> 2.8.3", ">= 2.8.3"
26
+ spec.add_dependency "activesupport", "~> 5.0.2", ">= 5.0.2"
27
+ spec.add_dependency "faraday_middleware", "~> 0.11.0"
28
+ spec.add_development_dependency "bundler", "~> 1.13"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ end
@@ -0,0 +1,191 @@
1
+ require_relative '../lib/bitmovin'
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
+ s3_input = Bitmovin::Encoding::Inputs::S3Input.new({
18
+ accessKey: AWS_ACCESS_KEY,
19
+ secretKey: AWS_SECRET_KEY,
20
+ bucketName: BUCKET_NAME
21
+ }).save!
22
+ s3_output = Bitmovin::Encoding::Outputs::S3Output.new({
23
+ accessKey: OUTPUT_AWS_ACCESS_KEY,
24
+ secretKey: OUTPUT_AWS_SECRET_KEY,
25
+ bucketName: BUCKET_NAME
26
+ }).save!
27
+
28
+ enc = Bitmovin::Encoding::Encodings::EncodingTask.new({
29
+ name: "VOD Encoding Ruby"
30
+ })
31
+ enc.save!
32
+
33
+ codec_config_720_700 = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new({
34
+ name: "H264 1280x720 700kb/s",
35
+ profile: "MAIN",
36
+ width: 1280,
37
+ height: 720,
38
+ bitrate: 700000
39
+ })
40
+ codec_config_720_700.save!
41
+ codec_config_720_1500 = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new({
42
+ name: "H264 1280x720 1500kb/s",
43
+ profile: "MAIN",
44
+ width: 1280,
45
+ height: 720,
46
+ bitrate: 1500000
47
+ })
48
+ codec_config_720_1500.save!
49
+ codec_config_720_2400 = Bitmovin::Encoding::CodecConfigurations::H264Configuration.new({
50
+ name: "H264 1280x720 2400kb/s",
51
+ profile: "MAIN",
52
+ width: 1280,
53
+ height: 720,
54
+ bitrate: 2400000
55
+ })
56
+ codec_config_720_2400.save!
57
+
58
+ audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.new({
59
+ name: "AAC_PROFILE_128k",
60
+ bitrate: 128000,
61
+ rate: 48000
62
+ })
63
+ audio_config.save!
64
+
65
+ stream_720_700 = enc.streams.build(name: 'H264 1280x720 700kb/s')
66
+ stream_720_700.codec_configuration = codec_config_720_700
67
+ stream_720_700.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
68
+ stream_720_700.save!
69
+
70
+ stream_720_1500 = enc.streams.build(name: 'H264 1280x720 1500/s')
71
+ stream_720_1500.codec_configuration = codec_config_720_1500
72
+ stream_720_1500.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
73
+ stream_720_1500.save!
74
+
75
+ stream_720_2400 = enc.streams.build(name: 'H264 1280x720 2400/s')
76
+ stream_720_2400.codec_configuration = codec_config_720_2400
77
+ stream_720_2400.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
78
+ stream_720_2400.save!
79
+
80
+ stream_aac = enc.streams.build(name: 'audio stream')
81
+ stream_aac.codec_configuration = audio_config
82
+ stream_aac.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')
83
+ stream_aac.save!
84
+
85
+ fmp4_muxing_720_700 = enc.muxings.fmp4.build(name: 'H264 1280x720 700kb/s', segment_length: 4)
86
+ fmp4_muxing_720_700.build_output({
87
+ output_id: s3_output.id,
88
+ output_path: File.join(OUTPUT_PATH, "video/720_700")
89
+ })
90
+ fmp4_muxing_720_700.streams << stream_720_700.id
91
+ fmp4_muxing_720_700.save!
92
+
93
+ fmp4_muxing_720_1500 = enc.muxings.fmp4.build(name: 'H264 1280x720 1500kb/s', segment_length: 4)
94
+ fmp4_muxing_720_1500.build_output({
95
+ output_id: s3_output.id,
96
+ output_path: File.join(OUTPUT_PATH, "video/720_1500")
97
+ })
98
+ fmp4_muxing_720_1500.streams << stream_720_1500.id
99
+ fmp4_muxing_720_1500.save!
100
+
101
+ fmp4_muxing_720_2400 = enc.muxings.fmp4.build(name: 'H264 1280x720 2400kb/s', segment_length: 4)
102
+ fmp4_muxing_720_2400.build_output({
103
+ output_id: s3_output.id,
104
+ output_path: File.join(OUTPUT_PATH, "video/720_2400")
105
+ })
106
+ fmp4_muxing_720_2400.streams << stream_720_2400.id
107
+ fmp4_muxing_720_2400.save!
108
+
109
+ audio_muxing = enc.muxings.fmp4.build(name: 'audio-muxing', segment_length: 4)
110
+ audio_muxing.build_output({
111
+ output_id: s3_output.id,
112
+ output_path: File.join(OUTPUT_PATH, "audio/aac")
113
+ })
114
+ audio_muxing.streams << stream_aac.id
115
+ audio_muxing.save!
116
+
117
+ enc.start!
118
+
119
+ while(enc.status != 'FINISHED')
120
+ puts "Encoding Status is #{enc.status}"
121
+ progress = enc.progress
122
+ if (progress > 0)
123
+ puts "Progress: #{enc.progress} %"
124
+ end
125
+ sleep 2
126
+ end
127
+ puts "Encoding finished!"
128
+
129
+
130
+
131
+ # Manifests
132
+
133
+ puts "Starting Manifest generation"
134
+ manifest = Bitmovin::Encoding::Manifests::DashManifest.new({
135
+ name: 'Test Ruby Manifest',
136
+ description: "Test encoding with ruby",
137
+ manifest_name: MPD_NAME
138
+ })
139
+
140
+ manifest.outputs << Bitmovin::Encoding::StreamOutput.new({
141
+ output_id: s3_output.id,
142
+ output_path: OUTPUT_PATH
143
+ })
144
+ manifest.save!
145
+
146
+ period = manifest.build_period()
147
+ period.save!
148
+
149
+ video_adaptationset = period.build_video_adaptationset()
150
+ video_adaptationset.save!
151
+
152
+ audio_adaptationset = period.build_audio_adaptationset({ lang: 'en' })
153
+ audio_adaptationset.save!
154
+
155
+ video_adaptationset.build_fmp4_representation({
156
+ encoding_id: enc.id,
157
+ muxing_id: fmp4_muxing_720_2400.id,
158
+ type: 'TEMPLATE',
159
+ segment_path: "video/720_2400"
160
+ }).save!
161
+ video_adaptationset.build_fmp4_representation({
162
+ encoding_id: enc.id,
163
+ muxing_id: fmp4_muxing_720_1500.id,
164
+ type: 'TEMPLATE',
165
+ segment_path: "video/720_1500"
166
+ }).save!
167
+ video_adaptationset.build_fmp4_representation({
168
+ encoding_id: enc.id,
169
+ muxing_id: fmp4_muxing_720_700.id,
170
+ type: 'TEMPLATE',
171
+ segment_path: "video/720_700"
172
+ }).save!
173
+
174
+ audio_adaptationset.build_fmp4_representation({
175
+ encoding_id: enc.id,
176
+ muxing_id: audio_muxing.id,
177
+ name: '1080p',
178
+ type: 'TEMPLATE',
179
+ segment_path: "audio/aac"
180
+ }).save!
181
+
182
+ manifest.start!
183
+
184
+ while(manifest.status != 'FINISHED')
185
+ puts "manifestoding Status is #{manifest.status}"
186
+ progress = manifest.progress
187
+ if (progress > 0)
188
+ puts "Progress: #{manifest.progress} %"
189
+ end
190
+ sleep 2
191
+ end
@@ -0,0 +1,7 @@
1
+ class BitmovinError < StandardError
2
+ attr_reader :resource
3
+
4
+ def initialize(resource)
5
+ @resource = resource
6
+ end
7
+ end
@@ -0,0 +1,41 @@
1
+ module Bitmovin
2
+ module ChildCollection
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ def child_collection(name, path, parameters, klass)
9
+ define_method("load_#{name}") do
10
+ vars = parameters.map { |p| instance_variable_get("@#{p}") }
11
+ url = path % vars
12
+ response = Bitmovin.client.get(url)
13
+
14
+ result(response)["items"].map do |item|
15
+ p = vars + [item]
16
+ klass.new(*p)
17
+ end
18
+ end
19
+ define_method(name) do
20
+ if !persisted?
21
+ raise "#{self.class.name.demodulize} is not persisted yet - can't load #{name}"
22
+ end
23
+ if instance_variable_get("@#{name}").nil?
24
+ items = send("load_#{name}")
25
+ instance_variable_set("@#{name}", items)
26
+ end
27
+ instance_variable_get("@#{name}")
28
+ end
29
+
30
+ define_method("build_#{ActiveSupport::Inflector.singularize(name)}") do |hash = {}|
31
+ instance_vars = parameters.map { |p| instance_variable_get("@#{p}") }
32
+ if !persisted?
33
+ raise "Period is not persisted yet - can't create #{ActiveSupport::Inflector.singularize(name)}"
34
+ end
35
+ instance_vars << hash
36
+ klass.new(*instance_vars)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,35 @@
1
+ module Bitmovin
2
+ class Client
3
+ attr_accessor :api_key
4
+ attr_accessor :base_url
5
+
6
+ def initialize(config)
7
+ @api_key = config[:api_key]
8
+ @base_url = "https://api.bitmovin.com/v1"
9
+ @conn = Faraday.new(url: @base_url, headers: {
10
+ 'X-Api-Key' => @api_key,
11
+ 'X-Api-Client-Version' => Bitmovin::VERSION,
12
+ 'X-Api-Client' => 'bitmovin-ruby',
13
+ 'Content-Type' => 'application/json'
14
+ }) do |faraday|
15
+
16
+ faraday.request :json
17
+ #faraday.response :logger
18
+ faraday.adapter :httpclient
19
+ faraday.response :raise_error
20
+ end
21
+ end
22
+
23
+ def get(*args, &block)
24
+ @conn.get *args, &block
25
+ end
26
+
27
+ def delete(*args, &block)
28
+ @conn.delete *args, &block
29
+ end
30
+
31
+ def post(*args, &block)
32
+ @conn.post *args, &block
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,4 @@
1
+ module Bitmovin
2
+ class ConfigurationResource < Resource
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module Bitmovin::Encoding::CodecConfigurations
2
+ class AacConfiguration < Bitmovin::ConfigurationResource
3
+ init 'encoding/configurations/audio/aac'
4
+ attr_accessor :id, :name, :description, :created_at, :modified_at
5
+ attr_accessor :bitrate, :rate, :channel_layout, :volume_adjust, :normalize
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Bitmovin::Encoding::CodecConfigurations
2
+ class H264Configuration < Bitmovin::ConfigurationResource
3
+ init 'encoding/configurations/video/h264'
4
+
5
+ attr_accessor :id, :created_at, :modified_at, :name, :description
6
+ attr_accessor :width, :height, :bitrate, :rate, :profile, :bframes, :ref_frames, :qp_min, :qp_max, :mv_prediction_mode, :mv_search_range_max, :cabac, :max_bitrate, :min_bitrate, :bufsize
7
+ attr_accessor :min_gop, :max_gop, :level, :b_adaptive_strategy, :motion_estimation_method, :rc_look_ahead, :sub_me, :trellis, :partitions, :slices, :interlace_mode
8
+ end
9
+ end