title: Live stream video of Selenium scripts/bots
body: <p>I would like to stream video footage of running Selenium scripts/bots. I'm using <a href="https://github.com/teamcapybara/capybara" rel="nofollow noreferrer">capybara</a> with <a href="https://github.com/SeleniumHQ/selenium/tree/master/rb" rel="nofollow noreferrer">selenium-webdriver</a> and I know I can use <a href="https://github.com/leonid-shevtsov/headless#capturing-video" rel="nofollow noreferrer">headless</a> to capture video. </p>
  
  <p>What I don't know how to do is stream the video such that I can access it at some URL and not consume disk space. Has anyone done this?</p>
  
  <p>Here's a test script I use to generate video files:</p>
  
  <pre><code>require 'capybara/dsl'
  require 'selenium-webdriver'
  require 'headless'
  
  Capybara.configure do |c|
    c.javascript_driver = :selenium
    c.default_driver = :selenium
  end
  
  Capybara.register_driver :selenium do |app|
    profile = Selenium::WebDriver::Chrome::Profile.new
    profile['general.useragent.override'] = Bot::USER_AGENT
    Capybara::Selenium::Driver.new(app, { 
      browser: :chrome,
      profile: profile,
      args: ['--window-size=1024,768'] 
    })
  end
  
  class Bot
    include Capybara::DSL
  
    USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'
  
    def run
      headless = Headless.new
      headless.start
      headless.video.start_capture
  
      loop do
        visit('http://google.com')
        sleep 1
        visit('http://youtube.com')
        sleep 1
        headless.video.stop_and_save("video-#{Time.now.to_i}.mov")
      end
    end
  end
  
  bot = Bot.new
  bot.run
  </code></pre>