Class: HLS::Poster

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input:, output:, width:, height:) ⇒ Poster

Returns a new instance of Poster.



15
16
17
18
19
20
# File 'lib/hls.rb', line 15

def initialize(input:, output:, width:, height:)
  @input = input
  @output = output.join("poster.jpg")
  @width = width
  @height = height
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



13
14
15
# File 'lib/hls.rb', line 13

def height
  @height
end

#inputObject (readonly)

Returns the value of attribute input.



13
14
15
# File 'lib/hls.rb', line 13

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



13
14
15
# File 'lib/hls.rb', line 13

def output
  @output
end

#widthObject (readonly)

Returns the value of attribute width.



13
14
15
# File 'lib/hls.rb', line 13

def width
  @width
end

Instance Method Details

#commandObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hls.rb', line 22

def command
  [
    # invoke ffmpeg
    "ffmpeg",
    # overwrite output files without confirmation
    "-y",
    # input video file
    "-i", input,
    # scale video to target resolution
    "-vf", "scale=w=#{width}:h=#{height}:force_original_aspect_ratio=decrease",
    # extract only one frame
    "-frames:v", "1",
    # output file path
    output
  ]
end