Class: FFMpeg
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(hash = {}) ⇒ FFMpeg
constructor
A new instance of FFMpeg.
- #options ⇒ Object
- #play ⇒ Object
- #rec(file, sec, quiet = true) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Player
Constructor Details
Instance Method Details
#command ⇒ Object
15 16 17 |
# File 'lib/player/ffmpeg.rb', line 15 def command 'ffmpeg' end |
#options ⇒ Object
19 20 21 |
# File 'lib/player/ffmpeg.rb', line 19 def map{ |k,v| "-#{k} #{v}"}*' ' end |
#play ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/player/ffmpeg.rb', line 30 def play self['f'] = 'mpegts' @output = '-' cmd = "#{to_s} | #{@mplayer}" $stderr.puts 'play: '+cmd `#{cmd}` raise $? unless $?.success? end |
#rec(file, sec, quiet = true) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/player/ffmpeg.rb', line 40 def rec(file, sec, quiet = true) self['t'] = sec if sec if quiet @output = file cmd = to_s else self['f'] = 'mpegts' @output = '-' cmd = %Q(#{to_s} | tee "#{file}" | #{@mplayer}) end puts "rec: #{cmd}" stdout, stderr, status = Open3.capture3(cmd) end |
#to_s ⇒ Object
24 25 26 27 |
# File 'lib/player/ffmpeg.rb', line 24 def to_s # novideoオプション -vn は、この位置でないと機能しない %Q(#{command} #{} -vn #{@output}) end |