vcs_ruby 1.1.8 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +1,37 @@
1
- #
2
- # Implementes MetaInfo Interface for FFmpeg
3
- #
4
-
5
- # MetaInformation = Struct.new(:duration, :bit_rate, :size, :format, :extension, :raw)
6
-
7
- require_relative '../time_index'
8
-
9
- module VCSRuby
10
- class FFmpegMetaInfo
11
- attr_reader :raw
12
-
13
- def initialize meta_info
14
- @raw = meta_info
15
- end
16
-
17
- def duration
18
- TimeIndex.new(@raw['duration'].to_f)
19
- end
20
-
21
- def bit_rate
22
- @raw['bit_rate'].to_i
23
- end
24
-
25
- def size
26
- @raw['size'].to_i
27
- end
28
-
29
- def format
30
- @raw['format_long_name']
31
- end
32
-
33
- def extension
34
- @raw['format_name']
35
- end
36
- end
1
+ #
2
+ # Implementes MetaInfo Interface for FFmpeg
3
+ #
4
+
5
+ # MetaInformation = Struct.new(:duration, :bit_rate, :size, :format, :extension, :raw)
6
+
7
+ require_relative '../time_index'
8
+
9
+ module VCSRuby
10
+ class FFmpegMetaInfo
11
+ attr_reader :raw
12
+
13
+ def initialize meta_info
14
+ @raw = meta_info
15
+ end
16
+
17
+ def duration
18
+ TimeIndex.new(@raw['duration'].to_f)
19
+ end
20
+
21
+ def bit_rate
22
+ @raw['bit_rate'].to_i
23
+ end
24
+
25
+ def size
26
+ @raw['size'].to_i
27
+ end
28
+
29
+ def format
30
+ @raw['format_long_name']
31
+ end
32
+
33
+ def extension
34
+ @raw['format_name']
35
+ end
36
+ end
37
37
  end
@@ -1,56 +1,62 @@
1
- #
2
- # Implementes VideoStream Interface for FFmpeg
3
- #
4
-
5
- # VideoStream = Struct.new(:width, :height, :codec, :color_space, :bit_rate, :frame_rate, :aspect_ratio, :raw)
6
-
7
- module VCSRuby
8
- class FFmpegVideoStream
9
- attr_reader :raw
10
-
11
- def initialize video_stream
12
- @raw = video_stream
13
- end
14
-
15
- def width
16
- @raw['width'].to_i
17
- end
18
-
19
- def height
20
- @raw['height'].to_i
21
- end
22
-
23
- def codec short = false
24
- if short
25
- @raw['codec_name']
26
- else
27
- @raw['codec_long_name']
28
- end
29
- end
30
-
31
- def color_space
32
- if ["unknown", "", nil].include? @raw['color_space']
33
- @raw['pix_fmt']
34
- else
35
- @raw['color_space']
36
- end
37
- end
38
-
39
- def bit_rate
40
- @raw['bit_rate'].to_i
41
- end
42
-
43
-
44
- def frame_rate
45
- if @raw['r_frame_rate']
46
- @raw['r_frame_rate'].to_r
47
- elsif @raw['avg_frame_rate']
48
- @raw['avg_frame_rate'].to_r
49
- end
50
- end
51
-
52
- def aspect_ratio
53
- @raw['display_aspect_ratio']
54
- end
55
- end
56
- end
1
+ #
2
+ # Implementes VideoStream Interface for FFmpeg
3
+ #
4
+
5
+ # VideoStream = Struct.new(:width, :height, :codec, :color_space, :bit_rate, :frame_rate, :aspect_ratio, :raw)
6
+
7
+ module VCSRuby
8
+ class FFmpegVideoStream
9
+ attr_reader :raw
10
+
11
+ def initialize video_stream
12
+ @raw = video_stream
13
+ end
14
+
15
+ def width
16
+ @raw['width'].to_i
17
+ end
18
+
19
+ def height
20
+ @raw['height'].to_i
21
+ end
22
+
23
+ def codec short = false
24
+ if short
25
+ @raw['codec_name']
26
+ else
27
+ @raw['codec_long_name']
28
+ end
29
+ end
30
+
31
+ def color_space
32
+ if ["unknown", "", nil].include? @raw['color_space']
33
+ @raw['pix_fmt']
34
+ else
35
+ @raw['color_space']
36
+ end
37
+ end
38
+
39
+ def bit_rate
40
+ @raw['bit_rate'].to_i
41
+ end
42
+
43
+
44
+ def frame_rate
45
+ if @raw['r_frame_rate']
46
+ @raw['r_frame_rate'].to_r
47
+ elsif @raw['avg_frame_rate']
48
+ @raw['avg_frame_rate'].to_r
49
+ end
50
+ end
51
+
52
+ def aspect_ratio
53
+ colon = ":"
54
+ if @raw['display_aspect_ratio'].include? colon
55
+ w,h = @raw['display_aspect_ratio'].split(colon)
56
+ Rational(w,h)
57
+ else
58
+ @raw['display_aspect_ratio'].to_f
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,101 +1,101 @@
1
- #
2
- # MPlayer Abstraction
3
- #
4
-
5
- require 'capturer'
6
- require 'command'
7
-
8
- module VCSRuby
9
- class MPlayer < Capturer
10
-
11
- HEADER = 2
12
-
13
- attr_reader :info, :video_streams, :audio_streams
14
- def initialize video
15
- @video = video
16
- @mplayer = Command.new :mplayer, 'mplayer'
17
-
18
- detect_version if available?
19
- end
20
-
21
- def file_valid?
22
- return probe_meta_information
23
- end
24
-
25
- def name
26
- :mplayer
27
- end
28
-
29
- def available?
30
- @mplayer.available?
31
- end
32
-
33
- def detect_version
34
- info = @mplayer.execute('')
35
- match = /MPlayer (.*),/.match(info)
36
- @version = match[1] if match
37
- end
38
-
39
- def grab time, image_path
40
- @mplayer.execute "-vo png -ss #{time.total_seconds} -endpos 0 \"#{@video.full_path}\""
41
- FileUtils.mv(file_pattern(1), image_path)
42
- end
43
-
44
- def available_formats
45
- # Ordered by priority
46
- image_formats = ['png', 'jpeg']
47
- formats = []
48
-
49
- list = @mplayer.execute("-vo help", 0, true)
50
- list.lines.drop(HEADER).each do |codec|
51
- name = format_split(codec)
52
- formats << name if image_formats.include?(name)
53
- end
54
-
55
- image_formats.select{ |format| formats.include?(format) }.map(&:to_sym)
56
- end
57
-
58
- def to_s
59
- "MPlayer #{@version}"
60
- end
61
-
62
- private
63
- def format_split line
64
- name = line.strip.split(' ', 2).first
65
- end
66
-
67
- def check_cache
68
- unless @cache
69
- @cache = @mplayer.execute("-ao null -vo null -identify -frames 0 -really-quiet \"#{@video.full_path}\"")
70
- end
71
- end
72
-
73
- def parse_format
74
- mplayer_hash = get_hash(@cache)
75
- @info = MPlayerMetaInfo.new(mplayer_hash, File.size(@video.full_path))
76
- return true
77
- end
78
-
79
- def parse_audio_streams
80
- @audio_streams = []
81
- mplayer_hash = get_hash(@cache)
82
- @audio_streams << MPlayerAudioStream.new(mplayer_hash)
83
- return true
84
- end
85
-
86
- def parse_video_streams
87
- @video_streams = []
88
- mplayer_hash = get_hash(@cache)
89
- @video_streams << MPlayerVideoStream.new(mplayer_hash)
90
- return true
91
- end
92
-
93
- def file_pattern n
94
- if format == :jpeg
95
- "#{"%08d" % n}.jpg"
96
- else
97
- "#{"%08d" % n}.#{format.to_s}"
98
- end
99
- end
100
- end
101
- end
1
+ #
2
+ # MPlayer Abstraction
3
+ #
4
+
5
+ require 'capturer'
6
+ require 'command'
7
+
8
+ module VCSRuby
9
+ class MPlayer < Capturer
10
+
11
+ HEADER = 2
12
+
13
+ attr_reader :info, :video_streams, :audio_streams
14
+ def initialize video
15
+ @video = video
16
+ @mplayer = Command.new :mplayer, 'mplayer'
17
+
18
+ detect_version if available?
19
+ end
20
+
21
+ def file_valid?
22
+ return probe_meta_information
23
+ end
24
+
25
+ def name
26
+ :mplayer
27
+ end
28
+
29
+ def available?
30
+ @mplayer.available?
31
+ end
32
+
33
+ def detect_version
34
+ info = @mplayer.execute('')
35
+ match = /MPlayer (.*),/.match(info)
36
+ @version = match[1] if match
37
+ end
38
+
39
+ def grab time, image_path
40
+ @mplayer.execute "-vo png -ss #{time.total_seconds} -endpos 0 \"#{@video.full_path}\""
41
+ FileUtils.mv(file_pattern(1), image_path)
42
+ end
43
+
44
+ def available_formats
45
+ # Ordered by priority
46
+ image_formats = ['png', 'jpeg']
47
+ formats = []
48
+
49
+ list = @mplayer.execute("-vo help", 0, true)
50
+ list.lines.drop(HEADER).each do |codec|
51
+ name = format_split(codec)
52
+ formats << name if image_formats.include?(name)
53
+ end
54
+
55
+ image_formats.select{ |format| formats.include?(format) }.map(&:to_sym)
56
+ end
57
+
58
+ def to_s
59
+ "MPlayer #{@version}"
60
+ end
61
+
62
+ private
63
+ def format_split line
64
+ name = line.strip.split(' ', 2).first
65
+ end
66
+
67
+ def check_cache
68
+ unless @cache
69
+ @cache = @mplayer.execute("-ao null -vo null -identify -frames 0 -really-quiet \"#{@video.full_path}\"")
70
+ end
71
+ end
72
+
73
+ def parse_format
74
+ mplayer_hash = get_hash(@cache)
75
+ @info = MPlayerMetaInfo.new(mplayer_hash, File.size(@video.full_path))
76
+ return true
77
+ end
78
+
79
+ def parse_audio_streams
80
+ @audio_streams = []
81
+ mplayer_hash = get_hash(@cache)
82
+ @audio_streams << MPlayerAudioStream.new(mplayer_hash)
83
+ return true
84
+ end
85
+
86
+ def parse_video_streams
87
+ @video_streams = []
88
+ mplayer_hash = get_hash(@cache)
89
+ @video_streams << MPlayerVideoStream.new(mplayer_hash)
90
+ return true
91
+ end
92
+
93
+ def file_pattern n
94
+ if format == :jpeg
95
+ "#{"%08d" % n}.jpg"
96
+ else
97
+ "#{"%08d" % n}.#{format.to_s}"
98
+ end
99
+ end
100
+ end
101
+ end
@@ -1,34 +1,34 @@
1
- #
2
- # Implementes AudioStream Interface for MPlayer
3
- #
4
-
5
- # AudioStream = Struct.new(:codec, :channels, :channel_layout, :sample_rate, :bit_rate, :raw)
6
- module VCSRuby
7
- class MPlayerAudioStream
8
- attr_reader :raw
9
-
10
- def initialize audio_stream
11
- @raw = audio_stream
12
- end
13
-
14
- def codec short = false
15
- @raw['ID_AUDIO_CODEC']
16
- end
17
-
18
- def channels
19
- @raw['ID_AUDIO_NCH'].to_i
20
- end
21
-
22
- def channel_layout
23
- ''
24
- end
25
-
26
- def sample_rate
27
- @raw['ID_AUDIO_RATE'].to_i
28
- end
29
-
30
- def bit_rate
31
- @raw['ID_AUDIO_BITRATE'].to_i
32
- end
33
- end
1
+ #
2
+ # Implementes AudioStream Interface for MPlayer
3
+ #
4
+
5
+ # AudioStream = Struct.new(:codec, :channels, :channel_layout, :sample_rate, :bit_rate, :raw)
6
+ module VCSRuby
7
+ class MPlayerAudioStream
8
+ attr_reader :raw
9
+
10
+ def initialize audio_stream
11
+ @raw = audio_stream
12
+ end
13
+
14
+ def codec short = false
15
+ @raw['ID_AUDIO_CODEC']
16
+ end
17
+
18
+ def channels
19
+ @raw['ID_AUDIO_NCH'].to_i
20
+ end
21
+
22
+ def channel_layout
23
+ ''
24
+ end
25
+
26
+ def sample_rate
27
+ @raw['ID_AUDIO_RATE'].to_i
28
+ end
29
+
30
+ def bit_rate
31
+ @raw['ID_AUDIO_BITRATE'].to_i
32
+ end
33
+ end
34
34
  end
@@ -1,40 +1,40 @@
1
- #
2
- # Implementes MetaInfo Interface for MPlayer
3
- #
4
-
5
- # MetaInformation = Struct.new(:duration, :bit_rate, :size, :format, :extension, :raw)
6
-
7
- require_relative '../time_index'
8
-
9
- module VCSRuby
10
- class MPlayerMetaInfo
11
- attr_reader :raw
12
-
13
- def initialize meta_info, filesize
14
- @raw = meta_info
15
- @filesize = filesize
16
- end
17
-
18
- def duration
19
- TimeIndex.new(@raw['ID_LENGTH'].to_f)
20
- end
21
-
22
- def bit_rate
23
- @raw['ID_AUDIO_BITRATE'].to_i + @raw['ID_VIDEO_BITRATE'].to_i
24
- end
25
-
26
- def size
27
- @filesize
28
- end
29
-
30
- def format
31
- extension
32
- end
33
-
34
- def extension
35
- ext = File.extname(@raw['ID_FILENAME'])
36
- ext[0] = ''
37
- ext
38
- end
39
- end
1
+ #
2
+ # Implementes MetaInfo Interface for MPlayer
3
+ #
4
+
5
+ # MetaInformation = Struct.new(:duration, :bit_rate, :size, :format, :extension, :raw)
6
+
7
+ require_relative '../time_index'
8
+
9
+ module VCSRuby
10
+ class MPlayerMetaInfo
11
+ attr_reader :raw
12
+
13
+ def initialize meta_info, filesize
14
+ @raw = meta_info
15
+ @filesize = filesize
16
+ end
17
+
18
+ def duration
19
+ TimeIndex.new(@raw['ID_LENGTH'].to_f)
20
+ end
21
+
22
+ def bit_rate
23
+ @raw['ID_AUDIO_BITRATE'].to_i + @raw['ID_VIDEO_BITRATE'].to_i
24
+ end
25
+
26
+ def size
27
+ @filesize
28
+ end
29
+
30
+ def format
31
+ extension
32
+ end
33
+
34
+ def extension
35
+ ext = File.extname(@raw['ID_FILENAME'])
36
+ ext[0] = ''
37
+ ext
38
+ end
39
+ end
40
40
  end
@@ -1,44 +1,44 @@
1
- #
2
- # Implementes VideoStream Interface for MPlayer
3
- #
4
-
5
- # VideoStream = Struct.new(:width, :height, :codec, :color_space, :bit_rate, :frame_rate, :aspect_ratio, :raw)
6
-
7
- module VCSRuby
8
- class MPlayerVideoStream
9
- attr_reader :raw
10
-
11
- def initialize video_stream
12
- @raw = video_stream
13
- end
14
-
15
- def width
16
- @raw['ID_VIDEO_WIDTH'].to_i
17
- end
18
-
19
- def height
20
- @raw['ID_VIDEO_HEIGHT'].to_i
21
- end
22
-
23
- def codec short = false
24
- @raw['ID_VIDEO_FORMAT']
25
- end
26
-
27
- def color_space
28
- ''
29
- end
30
-
31
- def bit_rate
32
- @raw['ID_VIDEO_BITRATE'].to_i
33
- end
34
-
35
-
36
- def frame_rate
37
- @raw['ID_VIDEO_FPS'].to_f
38
- end
39
-
40
- def aspect_ratio
41
- ''
42
- end
43
- end
44
- end
1
+ #
2
+ # Implementes VideoStream Interface for MPlayer
3
+ #
4
+
5
+ # VideoStream = Struct.new(:width, :height, :codec, :color_space, :bit_rate, :frame_rate, :aspect_ratio, :raw)
6
+
7
+ module VCSRuby
8
+ class MPlayerVideoStream
9
+ attr_reader :raw
10
+
11
+ def initialize video_stream
12
+ @raw = video_stream
13
+ end
14
+
15
+ def width
16
+ @raw['ID_VIDEO_WIDTH'].to_i
17
+ end
18
+
19
+ def height
20
+ @raw['ID_VIDEO_HEIGHT'].to_i
21
+ end
22
+
23
+ def codec short = false
24
+ @raw['ID_VIDEO_FORMAT']
25
+ end
26
+
27
+ def color_space
28
+ ''
29
+ end
30
+
31
+ def bit_rate
32
+ @raw['ID_VIDEO_BITRATE'].to_i
33
+ end
34
+
35
+
36
+ def frame_rate
37
+ @raw['ID_VIDEO_FPS'].to_f
38
+ end
39
+
40
+ def aspect_ratio
41
+ ''
42
+ end
43
+ end
44
+ end
data/lib/black.yml CHANGED
@@ -1,12 +1,12 @@
1
- style:
2
- header:
3
- color: White
4
- background: Black
5
- title:
6
- color: White
7
- background: Black
8
- contact:
9
- background: Black
10
- signature:
11
- color: White
12
- background: Black
1
+ style:
2
+ header:
3
+ color: White
4
+ background: Black
5
+ title:
6
+ color: White
7
+ background: Black
8
+ contact:
9
+ background: Black
10
+ signature:
11
+ color: White
12
+ background: Black