Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added an option to specify the codec used for video recording #25

Merged
merged 4 commits into from

3 participants

This page is out of date. Refresh to see the latest.
View
3  lib/headless/video/video_recorder.rb
@@ -13,6 +13,7 @@ def initialize(display, dimensions, options = {})
@pid_file_path = options.fetch(:pid_file_path, "/tmp/.headless_ffmpeg_#{@display}.pid")
@tmp_file_path = options.fetch(:tmp_file_path, "/tmp/.headless_ffmpeg_#{@display}.mov")
@log_file_path = options.fetch(:log_file_path, "/dev/null")
+ @codec = options.fetch(:codec, "qtrle")
end
def capture_running?
@@ -20,7 +21,7 @@ def capture_running?
end
def start_capture
- CliUtil.fork_process("#{CliUtil.path_to('ffmpeg')} -y -r 30 -g 600 -s #{@dimensions} -f x11grab -i :#{@display} -vcodec qtrle #{@tmp_file_path}", @pid_file_path, @log_file_path)
+ CliUtil.fork_process("#{CliUtil.path_to('ffmpeg')} -y -r 30 -g 600 -s #{@dimensions} -f x11grab -i :#{@display} -vcodec #{@codec} #{@tmp_file_path}", @pid_file_path, @log_file_path)
at_exit do
stop_and_discard
end
View
2  spec/headless_spec.rb
@@ -1,4 +1,4 @@
-require 'lib/headless'
+require 'spec_helper'
describe Headless do
before do
View
3  spec/spec_helper.rb
@@ -0,0 +1,3 @@
+$LOAD_PATH << File.expand_path(File.join('..', 'lib'), File.dirname(__FILE__))
+
+require 'headless'
View
8 spec/video_recorder_spec.rb
@@ -23,6 +23,14 @@
recorder = Headless::VideoRecorder.new(99, "1024x768x32")
recorder.start_capture
end
+
+ it "starts ffmpeg with specified codec" do
+ Headless::CliUtil.stub(:path_to, 'ffmpeg').and_return('ffmpeg')
+ Headless::CliUtil.should_receive(:fork_process).with(/ffmpeg -y -r 30 -g 600 -s 1024x768x32 -f x11grab -i :99 -vcodec libvpx/, "/tmp/.headless_ffmpeg_99.pid", '/dev/null')
+
+ recorder = Headless::VideoRecorder.new(99, "1024x768x32", {:codec => 'libvpx'})
+ recorder.start_capture
+ end
end
context "stopping video recording" do
Something went wrong with that request. Please try again.