Class: UnimatrixCLI::Alchemist::VideoEncoder::EncodeCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/unimatrix_cli/alchemist/video_encoder/encode_command.rb

Instance Method Summary collapse

Methods inherited from Command

available_commands, descendants, #initialize, #read_file, #validate, #validate_collection, #write

Methods included from UnimatrixParser

included

Constructor Details

This class inherits a constructor from UnimatrixCLI::Command

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/unimatrix_cli/alchemist/video_encoder/encode_command.rb', line 14

def execute
  video_encoder = query_encoder_for_rendition_profiles
  if validate( video_encoder, 'Alchemist::VideoEncoder' )
    rendition_profiles = video_encoder.rendition_profiles
    
    unless validate_collection( rendition_profiles, 'Alchemist::RenditionProfile' )
      rendition_profiles = assign_default_rendition_profiles_to_encoder
    end

    if validate_collection( rendition_profiles, 'Alchemist::RenditionProfile' )
      video_encoder = assign_video_to_encoder

      if validate( video_encoder, 'Alchemist::VideoEncoder' )
        video = video_encoder.videos.first

        if validate( video, 'Alchemist::Video' )

          rendition_profiles.map do | rendition_profile | 
            write( message: rendition_profile.uuid )
          end
        else
          write( 
            message: "Error assigning video to video_encoder: #{ video.inspect }",
            error: true
          )
        end
      else
        write( 
          message: "Error assigning video to " +
            "video_encoder: #{ video_encoder.inspect }",
          error: true
        )
      end
    else
      write( 
        message: "Error assigning rendition_profiles " +
          "to video_encoder: #{ rendition_profiles.inspect }", 
        error: true 
      )
    end
  else
    write(
      message: "Error querying for rendition_profiles. " +
        "Video Encoder not found: #{ video_encoder.inspect }",
      error: true
    )
  end
end