Class: Bitmovin::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bitmovin/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/bitmovin/client.rb', line 5

def initialize(api_key)
  Bitmovin.api_key = api_key
end

Instance Method Details

#create_encoding_profile(params = {}) ⇒ Bitmovin::EncodingProfile

Create new encoding profile

Examples:

client = Bitmovin::Client.new "somefuncykey"

encoding_profile = client.create_encoding_profile(
  name: "New profile",
  video_stream_configs: [
    {
      default_stream_id: 0,
      bitrate: 1024000,
      profile: "Main",
      preset: "Standard",
      codec: "h264",
      height: 480,
      width: 204
    }
  ],
  audio_stream_configs: [
    {
      default_stream_id: 0,
      bitrate: 256000
    }
  ]
)

Parameters:

  • params (defaults to: {})

    Encoding profile video & audio configurations

Options Hash (params):

  • :name (String)

    Name of new Encoding profile

  • :rotation (Number)

    Rotation of the video in degrees. A positive value will rotate the video clockwise and a negative one counter clockwise.

  • :segment_length (Hash)

    Only available using standard speed. Defines the length of a segment. Must be a value between 1 and 9 seconds.

  • :video_stream_configs (Array<Hash>)

    An array of video profile configs

    • :default_stream_id ID of the video stream which should be encoded

    • :representation_id ID of the video stream config

    • :bitrate Bitrate of the video stream. Value must be in the range from 32000 to 20000000

    • :profile Profile which should be used to encode video stream. Possible values are: baseline, main, high

    • :preset Preset which should be used to encode video stream. Possible values are: standard, professional, premium

    • :height Video-Width in px, must be in the range from 128 to 7680

    • :width Video-Height in px, must be in the range from 96 to 4320

    • :rate Only available using standard speed. The sample rate the encoded video should have in FPS. Values must be in the range from 1 to 120

    • :codec Only available using premium speed. Sets the video codec used for encoding. Possible values are: h264, hevc. Default value is h264.

    • :b_frames Sets the amount of B-Frames. Valid value range: 0 - 16

    • :ref_frames Sets the amount of Reference-Frames. Valid value range: 0 - 16

    • :qp_min Sets the minimum of quantization-factor. Valid value range: 0 - 69

    • :qp_max Sets the maximum of quantization-factor. Valid value range: 0 - 69

    • :mv_prediction_mode Sets the Motion Vector Prediction Mode. Valid values: none, spatial, temporal, auto

    • :mv_search_range_max Sets the maximum Motion-Vector-Search-Range. Valid value range: 16 - 24

    • :no_cabac Disable CABAC.

  • :audio_stream_configs (Array<Hash>)

    An array of audio profile configs

    • :default_stream_id ID of the audio stream which should be encoded

    • :representation_id ID of the audio stream config

    • :bitrate Bitrate of the audio stream. Values must be in the range from 8000 to 256000

    • :rate The sample rate the encoded audio should have in Hz. Possible values are: 0, 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000

  • :watermark_config (Hash)

    A watermark config

    • :top Distance between the top of the watermark image and the top of the input video

    • :left Distance between the left side of the watermark image and the left side of the input video

    • :bottom Distance between the bottom of the watermark image and the bottom of the input video

    • :right Distance between the right of the watermark image and the right of the input video

  • :cropping_config (Hash)

    crop configuration

    • :top Amount of pixel which will be cropped of the input video from the top.

    • :left Amount of pixel which will be cropped of the input video from the left side.

    • :bottom Amount of pixel which will be cropped of the input video from the bottom.

    • :right Amount of pixel which will be cropped of the input video from the right side.

Returns:



106
107
108
# File 'lib/bitmovin/client.rb', line 106

def create_encoding_profile(params = {})
  Bitmovin::EncodingProfile.create(params)
end

#create_input(url, params) ⇒ Bitmovin::Input #create_input(params) ⇒ Bitmovin::Input

Creates new input

Overloads:

  • #create_input(url, params) ⇒ Bitmovin::Input

    Examples:

    client = Bitmovin::Client.new "somefuncykey"
    input = client.create_input("https://bucket-name.s3.amazonaws.com/path/to/file.txt",
      type: 's3',
      access_key: "awsS3Key",
      secret_key: "awsS3Secret"
    )

    Parameters:

    • url (String)

      url of input for URL, S3 or Aspera inputs

    • params (String)

      input params

    Options Hash (params):

    • :async (Boolean)

      Create input async

    • :type (String)

      Type of input

    • :username (String)

      Basic auth username

    • :password (String)

      Basic auth password

    • :region (String) — default: 'us-east-1'

      S3 bucket region

    • :bucket (String)

      S3 bucket name for s3 input, also can be infered from url

    • :object_key (String)

      S3 object name with containing folder, can be infered from url

    • :access_key (String)

      S3 or GCS access key, required for S3 or GCS inputs

    • :secret_key (String)

      S3 or GCS secret, required for S3 or GCS inputs

    • :account_name (String)

      MS Azure account name, required for Azure inputs

    • :account_key (String)

      MS Azure account key, required for Azure inputs

    • :container (String)

      MS Azure storage container name

    • :min_bandwidth, (String)

      Minimal download bandwidth

    • :max_bandwidth, (String)

      Maximal download bandwidth

  • #create_input(params) ⇒ Bitmovin::Input

    Examples:

    client = Bitmovin::Client.new "somefuncykey"
    
    client.create_input(
      bucket: "bucket-name",
      object_key: "/path/to/file.txt",
      type: 's3',
      access_key: "awsS3Key",
      secret_key: "awsS3Secret"
    )

    Parameters:

    • params (String)

      input params

    Options Hash (params):

    • :async (Boolean)

      Create input async

    • :type (String)

      Type of input

    • :url (String)

      Aspera/Azure file url

    • :username (String)

      Basic auth username

    • :password (String)

      Basic auth password

    • :region (String) — default: 'us-east-1'

      S3 bucket region

    • :bucket (String)

      S3 bucket name for s3 input, also can be infered from url

    • :object_key (String)

      S3 object name with containing folder, can be infered from url

    • :access_key (String)

      S3 or GCS access key, required for S3 or GCS inputs

    • :secret_key (String)

      S3 or GCS secret, required for S3 or GCS inputs

    • :account_name (String)

      MS Azure account name, required for Azure inputs

    • :account_key (String)

      MS Azure account key, required for Azure inputs

    • :container (String)

      MS Azure storage container name

    • :min_bandwidth, (String)

      Minimal download bandwidth

    • :max_bandwidth, (String)

      Maximal download bandwidth

Returns:



170
171
172
# File 'lib/bitmovin/client.rb', line 170

def create_input(*args)
  Bitmovin::Input.create(*args)
end

#create_job(params = {}) ⇒ Bitmovin::Job

Creates a new encoding job

Examples:

client = Bitmovin::Client.new "somefuncykey"

job = client.create_job(
  input_id: 1,
  output_id: 1,
  encoding_profile_id: 1,
  manifest_types: ["mpd", "m3u8"]
)

Parameters:

  • params (Hash) (defaults to: {})

    Job details

Options Hash (params):

  • input_id (Integer)

    Job input id

  • output_id (Integer)

    Job output id

  • encoding_profile_id (Integer)

    Encoding profile id

  • audio_meta_data (Hash)

    Meta data of the audio streams (Only available when using standard as speed setting)

    • :default_stream_id (Integer) - Default stream id of the audio stream

    • :language (String) - Language abbreviation [ISO 639-1]

    • :label (String) - Label of the language field

  • manifest_types (Array<String>)

    Available values: mpd | m3u8

  • extract_closed_captinos (Boolean)

    Extract closed captions from the input file

  • deinterlace (Boolean)

    Create de-interlaced output

  • merge_audio_channel_configs (Hash)

    Merge multiple mono audio input streams to stereo or 5.1 audio streams (Only available when using standard as speed setting)

    • :audio_channels [Array] - Array of mono input streams

Returns:



37
38
39
# File 'lib/bitmovin/client.rb', line 37

def create_job(params = {})
  Bitmovin::Job.create(params)
end

#create_output(params = {}) ⇒ Bitmovin::Output

Create a new Bitmovin Output

Examples:

client = Bitmovin::Client.new "somefuncykey"

client.create_input(
  type: 's3',
  access_key: 'awsS3Key',
  secret_key: 'aswS3Secret',
  name: 'file.txt',
  prefix: '/path/to',
  bucket: "bucket-name"
)

Parameters:

  • params (Hash) (defaults to: {})

    Output details

Options Hash (params):

  • :type (String)

    Type of Output

  • :name (String)

    Name of output profile

  • :bucket (String)

    S3 Bucket name for s3 output

  • :region (String) — default: 'us-east-1'

    S3 region of bucket, required for S3 outputs

  • :access_key (String)

    S3/GCS Access Key, required for S3 outputs

  • :secret_key (String)

    S3/GCS Secret key, required for S3 outputs

  • :account_name (String)

    MS Azure account name, required for Azure outputs

  • :account_key (String)

    MS Azure account key, required for Azure outputs

  • :container (String)

    Name of Azure storage container

  • :prefix (String)

    Virtual sub-directory for file

  • :make_public (Boolean)

    If true, all transfered files can be accessed by their respective URL from anyone

  • :create_sub_directory (Boolean) — default: true

    if true, create a sub directory for your job (<job_id>_<hash>)

Returns:



205
206
207
# File 'lib/bitmovin/client.rb', line 205

def create_output(params = {})
  Bitmovin::Output.create(params)
end

#get_encoding_profiles_list(page = 1) ⇒ Array<Bitmovin::EncodingProfile>

Get list of available encoding profiles by pages per 10

Parameters:

  • page (Integer) (defaults to: 1)

    number of page

Returns:



225
226
227
# File 'lib/bitmovin/client.rb', line 225

def get_encoding_profiles_list(page = 1)
  Bitmovin::EncodingProfile.list(page)
end

#get_inputs_list(page = 1, reload = false) ⇒ Array<Bitmovin::Input>

Get lsit of available bitmovin inputs (10 per page)

Parameters:

  • page (Number) (defaults to: 1)

    page number

  • reload (Boolean) (defaults to: false)

    force reload

Returns:



248
249
250
# File 'lib/bitmovin/client.rb', line 248

def get_inputs_list(page = 1, reload = false)
  Bitmovin::Input.list(page, reload)
end

#get_jobs_list(status = :all, page = 1, reload = false) ⇒ Array<Bitmovin::Job>

Get list of available jobs (10 Jobs per page)

Parameters:

  • status (String, Symbol) (defaults to: :all)

    Available values: all | finished | enqueued | inprogress | error

  • page (Integer) (defaults to: 1)

    number of page

  • reload (Integer) (defaults to: false)

    Force reload from server

Returns:



236
237
238
# File 'lib/bitmovin/client.rb', line 236

def get_jobs_list(status = :all, page = 1, reload = false)
  Bitmovin::Job.list(status, page, reload)
end

#get_outputs_list(page = 1, reload = false) ⇒ Array<Bitmovin::Output>

Get lsit of available bitmovin outputs (10 per page)

Parameters:

  • page (Number) (defaults to: 1)

    page number

  • reload (Boolean) (defaults to: false)

    force reload

Returns:



260
261
262
# File 'lib/bitmovin/client.rb', line 260

def get_outputs_list(page = 1, reload = false)
  Bitmovin::Output.list(page, reload)
end

#transfer_job(params = {}) ⇒ Bitmovin::TransferJob

Transfer job result to destination outputs

Parameters:

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • job_id (Integer)

    Job-ID

  • output_id (Integer)

    Output-ID

Returns:



216
217
218
# File 'lib/bitmovin/client.rb', line 216

def transfer_job(params={})
  Bitmovin::TransferJob.create(params)
end