Class: RunApi::Runway::Resources::ExtendVideo

Inherits:
Object
  • Object
show all
Includes:
Core::ResourceHelpers
Defined in:
lib/runapi/runway/resources/extend_video.rb

Overview

Runway extend-video resource. Append additional footage to a previously generated video, continuing from where the source task left off.

Constant Summary collapse

ENDPOINT =
"/api/v1/runway/extend_video"
RESPONSE_CLASS =
Types::TaskCreateResponse
COMPLETED_RESPONSE_CLASS =
Types::CompletedTaskResponse
MODEL =
"runway"

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ ExtendVideo

Returns a new instance of ExtendVideo.



16
17
18
# File 'lib/runapi/runway/resources/extend_video.rb', line 16

def initialize(http)
  @http = http
end

Instance Method Details

#create(options: nil, **params) ⇒ RunApi::Runway::Types::TaskCreateResponse

Create an extend-video task without waiting for completion.

Parameters:

  • params (Hash)

    extend-video parameters (see #run for details)

Returns:



37
38
39
40
41
# File 'lib/runapi/runway/resources/extend_video.rb', line 37

def create(options: nil, **params)
  params = compact_params(params)
  validate_contract!(CONTRACT["extend-video"], params.merge(model: MODEL))
  request(:post, ENDPOINT, body: params, options: options)
end

#get(id, options: nil) ⇒ RunApi::Runway::Types::TaskResponse

Get extend-video task status by task ID.

Parameters:

  • id (String)

    task ID

Returns:



47
48
49
# File 'lib/runapi/runway/resources/extend_video.rb', line 47

def get(id, options: nil)
  request(:get, "#{ENDPOINT}/#{id}", options: options)
end

#run(options: nil, **params) ⇒ RunApi::Runway::Types::CompletedTaskResponse

Extend a video and wait until complete.

Parameters:

  • source_task_id (String)

    ID of the completed TextToVideo or ExtendVideo task to continue from

  • prompt (String)

    prompt describing the continuation footage

  • output_resolution (String)

    must match the resolution of the source task ("720p" or "1080p")

  • watermark (String, nil)

    watermark text burned into the output

  • callback_url (String, nil)

    webhook URL for completion notification

Returns:



28
29
30
31
# File 'lib/runapi/runway/resources/extend_video.rb', line 28

def run(options: nil, **params)
  task = create(options: options, **params)
  poll_until_complete { get(task.id, options: options) }
end