headless 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/README.md +7 -6
- data/headless.gemspec +1 -1
- data/lib/headless/video/video_recorder.rb +12 -4
- data/spec/video_recorder_spec.rb +30 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dc1c06f85049924c12fc40b4558040fd514c01a
|
4
|
+
data.tar.gz: a5e904086bdccf72798574e2450ce76b64fda0a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6ad825721817e789fde8d9786bac8fec26ef097e5fb4af74f8c685a9895dfa3b5850161f3bf8f809b5024a7827c08f35dfd131d843e2f0cc71b274b4197ddea
|
7
|
+
data.tar.gz: af0c4aea4a57b14f56868315a1874bf28a09e7ab8a4a91355d0b864e09e939794aa9eedcf9ced54692c79dc428ae5a30003ea43afaa097edaaf75b06ee85fd5f
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -131,12 +131,13 @@ headless = Headless.new(:video => { :frame_rate => 12, :codec => 'libx264' })
|
|
131
131
|
Available options:
|
132
132
|
|
133
133
|
* :codec - codec to be used by ffmpeg
|
134
|
-
* :frame_rate
|
135
|
-
* :provider
|
136
|
-
* :
|
137
|
-
* :
|
138
|
-
* :
|
139
|
-
* :
|
134
|
+
* :frame_rate - frame rate of video capture
|
135
|
+
* :provider - ffmpeg provider - either :libav (default) or :ffmpeg
|
136
|
+
* :provider_binary_path - Explicit path to avconv or ffmpeg. Only required when the binary cannot be discovered on the system $PATH.
|
137
|
+
* :pid_file_path - path to ffmpeg pid file, default: "/tmp/.headless_ffmpeg_#{@display}.pid"
|
138
|
+
* :tmp_file_path - path to tmp video file, default: "/tmp/.headless_ffmpeg_#{@display}.mov"
|
139
|
+
* :log_file_path - ffmpeg log file, default: "/dev/null"
|
140
|
+
* :extra - array of extra ffmpeg options, default: []
|
140
141
|
|
141
142
|
## Taking screenshots
|
142
143
|
|
data/headless.gemspec
CHANGED
@@ -4,6 +4,9 @@ class Headless
|
|
4
4
|
class VideoRecorder
|
5
5
|
attr_accessor :pid_file_path, :tmp_file_path, :log_file_path
|
6
6
|
|
7
|
+
# Allow end-users to override the path to the binary
|
8
|
+
attr_accessor :provider_binary_path
|
9
|
+
|
7
10
|
def initialize(display, dimensions, options = {})
|
8
11
|
@display = display
|
9
12
|
@dimensions = dimensions[/.+(?=x)/]
|
@@ -14,9 +17,14 @@ class Headless
|
|
14
17
|
@codec = options.fetch(:codec, "qtrle")
|
15
18
|
@frame_rate = options.fetch(:frame_rate, 30)
|
16
19
|
@provider = options.fetch(:provider, :libav) # or :ffmpeg
|
20
|
+
|
21
|
+
# If no provider_binary_path was specified, then
|
22
|
+
# make a guess based upon the provider.
|
23
|
+
@provider_binary_path = options.fetch(:provider_binary_path, guess_the_provider_binary_path)
|
24
|
+
|
17
25
|
@extra = Array(options.fetch(:extra, []))
|
18
26
|
|
19
|
-
CliUtil.ensure_application_exists!(
|
27
|
+
CliUtil.ensure_application_exists!(provider_binary_path, "#{provider_binary_path} not found on your system. Install it or change video recorder provider")
|
20
28
|
end
|
21
29
|
|
22
30
|
def capture_running?
|
@@ -55,8 +63,8 @@ class Headless
|
|
55
63
|
|
56
64
|
private
|
57
65
|
|
58
|
-
def
|
59
|
-
@provider
|
66
|
+
def guess_the_provider_binary_path
|
67
|
+
@provider== :libav ? 'avconv' : 'ffmpeg'
|
60
68
|
end
|
61
69
|
|
62
70
|
def command_line_for_capture
|
@@ -69,7 +77,7 @@ class Headless
|
|
69
77
|
end
|
70
78
|
|
71
79
|
([
|
72
|
-
CliUtil.path_to(
|
80
|
+
CliUtil.path_to(provider_binary_path),
|
73
81
|
"-y",
|
74
82
|
"-r #{@frame_rate}",
|
75
83
|
"-s #{dimensions}",
|
data/spec/video_recorder_spec.rb
CHANGED
@@ -1,17 +1,44 @@
|
|
1
1
|
require 'headless'
|
2
2
|
|
3
|
+
require 'tempfile'
|
4
|
+
|
3
5
|
describe Headless::VideoRecorder do
|
4
6
|
before do
|
5
7
|
stub_environment
|
6
8
|
end
|
7
9
|
|
8
10
|
describe "instantiation" do
|
9
|
-
|
11
|
+
|
12
|
+
it "throws an error if provider_binary_path is not installed" do
|
10
13
|
allow(Headless::CliUtil).to receive(:application_exists?).and_return(false)
|
14
|
+
expect { Headless::VideoRecorder.new(99, "1024x768x32") }.to raise_error(Headless::Exception)
|
11
15
|
end
|
12
16
|
|
13
|
-
it "
|
14
|
-
|
17
|
+
it "allows provider_binary_path to be specified" do
|
18
|
+
Tempfile.open('some_provider') do |f|
|
19
|
+
v = Headless::VideoRecorder.new(99, "1024x768x32", provider: :ffmpeg, provider_binary_path: f.path)
|
20
|
+
expect(v.provider_binary_path).to eq(f.path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "allows provider_binary_path to be specified" do
|
25
|
+
Tempfile.open('some_provider') do |f|
|
26
|
+
v = Headless::VideoRecorder.new(99, "1024x768x32", provider: :ffmpeg, provider_binary_path: f.path)
|
27
|
+
expect(v.provider_binary_path).to eq(f.path)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "provider_binary_path not specified" do
|
32
|
+
it "assumes the provider binary is 'ffmpeg' if the provider is :ffmpeg" do
|
33
|
+
v = Headless::VideoRecorder.new(99, "1024x768x32", provider: :ffmpeg)
|
34
|
+
expect(v.provider_binary_path).to eq("ffmpeg")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "assumes the provider binary is 'avconv' if the provider is :libav" do
|
38
|
+
v = Headless::VideoRecorder.new(99, "1024x768x32", provider: :libav)
|
39
|
+
expect(v.provider_binary_path).to eq("avconv")
|
40
|
+
end
|
41
|
+
|
15
42
|
end
|
16
43
|
end
|
17
44
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: headless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Shevtsov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -98,3 +98,4 @@ signing_key:
|
|
98
98
|
specification_version: 4
|
99
99
|
summary: Ruby headless display interface
|
100
100
|
test_files: []
|
101
|
+
has_rdoc:
|