Class: WebVideo::Adapters::FfmpegAdapter

Inherits:
AbstractAdapter show all
Defined in:
lib/web_video/adapters/ffmpeg_adapter.rb

Instance Attribute Summary

Attributes inherited from AbstractAdapter

#filename, #filepath, #path, #video_streams

Instance Method Summary collapse

Methods inherited from AbstractAdapter

#bitrate, #duration, #file_exists?, #initialize, #installed?, #run, #size, #streams, #video_stream

Constructor Details

This class inherits a constructor from WebVideo::Adapters::AbstractAdapter

Instance Method Details

#command_nameObject



14
15
16
# File 'lib/web_video/adapters/ffmpeg_adapter.rb', line 14

def command_name
  'ffmpeg'
end

#convert_commandObject



18
19
20
21
22
23
24
# File 'lib/web_video/adapters/ffmpeg_adapter.rb', line 18

def convert_command
  command = []
  command << "-i $input_file$"
  command << "-s $resolution$"
  
  command.dup
end

#duration_in_secondsObject

00:21:41.18



6
7
8
9
10
11
12
# File 'lib/web_video/adapters/ffmpeg_adapter.rb', line 6

def duration_in_seconds
  if @metadata[:duration] =~ /(\d+)\:(\d+)\:(\d+)\.(\d+)/
    ( $1.to_i * 60 * 60 ) + ( $2.to_i * 60 ) + ( $3.to_i ) + ( ($4.to_i/100) * 60 )
  else
    0
  end
end

#screenshot_commandObject



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
# File 'lib/web_video/adapters/ffmpeg_adapter.rb', line 26

def screenshot_command
  command = []
  command << "-i $input_file$"
    
  # Specifies the frame size of the output (Default is the size of the original video.)
  command << "-s $resolution$"
  
  # Frame rate of video. i.e. no. of frames to be extracted into images per second
  # The default value is 25
  command << "-r 1"
  
  # Disable audio recording.
  command << "-an"
  
  # Number of video frames to record
  command << "-vframes $count$"
  
  # Force format (image2|rawvideo)
  command << "-f $format$"
  
  # Start the extraction from particular point
  command << "-ss $at$"
  
  command.dup
end