Class: VCSRuby::FFmpeg
Constant Summary
collapse
10
- ENCODING_SUPPORT =
2
- VIDEO_CODEC =
3
- NAME =
8
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Capturer
create, #format, #format=, #format_extension, initialize_capturers
Constructor Details
#initialize(video) ⇒ FFmpeg
Returns a new instance of FFmpeg.
18
19
20
21
22
23
24
25
|
# File 'lib/FFmpeg/ffmpeg.rb', line 18
def initialize video
@video = video
@ffmpeg = Command.new :ffmpeg, 'ffmpeg'
@ffprobe = Command.new :ffmpeg, 'ffprobe'
@libav = nil
detect_version if available?
end
|
Instance Attribute Details
#audio_streams ⇒ Object
Returns the value of attribute audio_streams.
16
17
18
|
# File 'lib/FFmpeg/ffmpeg.rb', line 16
def audio_streams
@audio_streams
end
|
#info ⇒ Object
Returns the value of attribute info.
16
17
18
|
# File 'lib/FFmpeg/ffmpeg.rb', line 16
def info
@info
end
|
#video_streams ⇒ Object
Returns the value of attribute video_streams.
16
17
18
|
# File 'lib/FFmpeg/ffmpeg.rb', line 16
def video_streams
@video_streams
end
|
Instance Method Details
#available? ⇒ Boolean
35
36
37
|
# File 'lib/FFmpeg/ffmpeg.rb', line 35
def available?
@ffmpeg.available? && @ffprobe.available? && !libav?
end
|
57
58
59
|
# File 'lib/FFmpeg/ffmpeg.rb', line 57
def available_formats
@available_formats ||= available_formats_query
end
|
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/FFmpeg/ffmpeg.rb', line 61
def available_formats_query
image_formats = ['png', 'tiff', 'bmp', 'mjpeg']
formats = []
list = @ffprobe.execute "-codecs"
list.lines.drop().each do |codec|
name, e, v = format_split(codec)
formats << name if image_formats.include?(name) && e && v
end
image_formats.select{ |format| formats.include?(format) }.map(&:to_sym)
end
|
#detect_version ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/FFmpeg/ffmpeg.rb', line 43
def detect_version
info = @ffmpeg.execute('-version')
match = /avconv ([\d|\.|\-|:]*)/.match(info)
@libav = !!match
match = /ffmpeg version ([\d|\.]*)/.match(info)
if match
@version = match[1]
end
end
|
#file_valid? ⇒ Boolean
27
28
29
|
# File 'lib/FFmpeg/ffmpeg.rb', line 27
def file_valid?
return probe_meta_information
end
|
#grab(time, image_path) ⇒ Object
53
54
55
|
# File 'lib/FFmpeg/ffmpeg.rb', line 53
def grab time, image_path
@ffmpeg.execute "-y -ss #{time.total_seconds} -i \"#{@video.full_path}\" -an -dframes 1 -vframes 1 -vcodec #{format} -f rawvideo \"#{image_path}\""
end
|
#libav? ⇒ Boolean
39
40
41
|
# File 'lib/FFmpeg/ffmpeg.rb', line 39
def libav?
@libav
end
|
#name ⇒ Object
31
32
33
|
# File 'lib/FFmpeg/ffmpeg.rb', line 31
def name
:ffmpeg
end
|
#to_s ⇒ Object
75
76
77
|
# File 'lib/FFmpeg/ffmpeg.rb', line 75
def to_s
"FFmpeg #{@version}"
end
|