Class: VCSRuby::MPlayer
Constant Summary
collapse
2
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Capturer
create, #format, #format=, #format_extension, initialize_capturers
Constructor Details
#initialize(video) ⇒ MPlayer
Returns a new instance of MPlayer.
14
15
16
17
18
19
|
# File 'lib/MPlayer/mplayer.rb', line 14
def initialize video
@video = video
@mplayer = Command.new :mplayer, 'mplayer'
detect_version if available?
end
|
Instance Attribute Details
#audio_streams ⇒ Object
Returns the value of attribute audio_streams.
13
14
15
|
# File 'lib/MPlayer/mplayer.rb', line 13
def audio_streams
@audio_streams
end
|
#info ⇒ Object
Returns the value of attribute info.
13
14
15
|
# File 'lib/MPlayer/mplayer.rb', line 13
def info
@info
end
|
#video_streams ⇒ Object
Returns the value of attribute video_streams.
13
14
15
|
# File 'lib/MPlayer/mplayer.rb', line 13
def video_streams
@video_streams
end
|
Instance Method Details
#available? ⇒ Boolean
29
30
31
|
# File 'lib/MPlayer/mplayer.rb', line 29
def available?
@mplayer.available?
end
|
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/MPlayer/mplayer.rb', line 44
def available_formats
image_formats = ['png', 'jpeg']
formats = []
list = @mplayer.execute("-vo help", 0, true)
list.lines.drop(HEADER).each do |codec|
name = format_split(codec)
formats << name if image_formats.include?(name)
end
image_formats.select{ |format| formats.include?(format) }.map(&:to_sym)
end
|
#detect_version ⇒ Object
33
34
35
36
37
|
# File 'lib/MPlayer/mplayer.rb', line 33
def detect_version
info = @mplayer.execute('')
match = /MPlayer (.*),/.match(info)
@version = match[1] if match
end
|
#file_valid? ⇒ Boolean
21
22
23
|
# File 'lib/MPlayer/mplayer.rb', line 21
def file_valid?
return probe_meta_information
end
|
#grab(time, image_path) ⇒ Object
39
40
41
42
|
# File 'lib/MPlayer/mplayer.rb', line 39
def grab time, image_path
@mplayer.execute "-vo png -ss #{time.total_seconds} -endpos 0 \"#{@video.full_path}\""
FileUtils.mv(file_pattern(1), image_path)
end
|
#name ⇒ Object
25
26
27
|
# File 'lib/MPlayer/mplayer.rb', line 25
def name
:mplayer
end
|
#to_s ⇒ Object
58
59
60
|
# File 'lib/MPlayer/mplayer.rb', line 58
def to_s
"MPlayer #{@version}"
end
|