Skip to content
Browse files

Added an option to specify the codec used for video recording.

  • Loading branch information...
1 parent 1e0a1f0 commit 54afe23086f241ac23d865d55f06f52a8aab044a @gshakhn committed with Feb 9, 2012
Showing with 10 additions and 1 deletion.
  1. +2 −1 lib/headless/video/video_recorder.rb
  2. +8 −0 spec/video_recorder_spec.rb
View
3 lib/headless/video/video_recorder.rb
@@ -13,14 +13,15 @@ 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?
CliUtil.read_pid @pid_file_path
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
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

0 comments on commit 54afe23

Please sign in to comment.
Something went wrong with that request. Please try again.