我正在使用Headless gem使用xvfb创建无头会话并使用ffmpeg记录会话。我无法保存无头宝石创建的视频。我包含了我的代码和输出的相关片段。
码$LOGGER.info("----------Starting test: #{@test_name}----------")
if Utilities.linux? && ENV['DRIVER'] != 'sauce'
@headless = Headless.new ({dimension: '1600x1200x16',
pid_file_path: "#{Utilities.get_root_directory}/tmp/headless_ffmpeg_#{@display}.pid",
tmp_file_path: "#{Utilities.get_root_directory}/tmp/headless_ffmpeg_#{@display}.mov",
log_file_path: "#{Utilities.get_root_directory}/tmp/headless_ffmpeg_#{@display}.txt"})
@headless.start
@headless.video.start_capture
$LOGGER.info 'Creating headless session.'
end
$browser = DefaultWatir.initiate_browser(@test_name)
if Utilities.linux? && ENV['DRIVER'] != 'sauce'
$LOGGER.info "Starting video recording"
@headless.video.start_capture
end
......... .........
......... TEST RUN .........
......... .........
$LOGGER.info "----------Ending test: #{@test_name}----------"
puts "\n\n"
$browser.close if $browser
save_video if @headless
def video_path
return "#{Utilities.get_root_directory}/video/#{@test_name}_#{Time.now.to_s.gsub(' ', '-')}"
end
def save_video
if Utilities.linux? && ENV['DRIVER'] != 'sauce'
unless self.instance_variable_get(:@exception).nil? && !$has_errors
saved_video_path = video_path
Dir.mkdir("#{Utilities.get_root_directory}/video") unless Dir.exists?("#{Utilities.get_root_directory}/video")
$LOGGER.info "Video path = #{saved_video_path}"
begin
$LOGGER.info 'before save'
@headless.video.stop_and_save(saved_video_path)
$LOGGER.info 'after save'
rescue ex
$LOGGER.info 'Video save had exception.'
puts ex.message
puts ex.backtrace.join("\n\t")
end
$LOGGER.info "Video saved at: #{saved_video_path}"
else
@headless.video.stop_and_discard
end
@headless.destroy
end
end
产量
[INFO - 2015-03-06 21:58:37 +0000] - ----------开始测试:示例测试----------
[INFO - 2015-03-06 21:58:37 +0000] - 创建无头会话。
[INFO - 2015-03-06 21:58:40 +0000] - 开始录制视频
[INFO - 2015-03-06 22:02:04 +0000] - ----------结束测试:示例测试----------
INFO - 2015-03-06 22:02:05 +0000] - 视频路径= / var / lib / jenkins / workspace / end_to_end_firefox / selenium-tests / video / PoolPlayToSingleEliminationOneDivision_2015-03-06-22:02:05 - + 0000
[INFO - 2015-03-06 22:02:05 +0000] - 保存之前
[INFO - 2015-03-06 22:02:05 +0000] - 保存后
[INFO - 2015-03-06 22:02:05 +0000] - 视频保存在:/ var / lib / jenkins / workspace / end_to_end_firefox / selenium-tests / video / PoolPlayToSingleEliminationOneDivision_2015-03-06-22:02 :05- + 0000