title: How to pass Ruby's STDIN to an external program called by Open3.popen3?
body: <p>I would like to call ffmpeg from a Ruby script, lets call "vpipe", and I want this Ruby script to act as a filter like command: take its input from a pipe. Its only purpose is to select the first audio stream and delete chapters data if exists:</p>
  
  <pre><code>#!/usr/bin/ruby
  require "open3"
  
  output_file=ARGV[0]
  
  cmd=%Q{ffmpeg -y -i - -map 0:v -map 0:a -c:v copy -c:a:0 copy -map_chapters -1 #{output_file}}
  
  Open3.popen3(cmd,:stdin_data=&gt;STDIN)
  </code></pre>
  
  <p>Then I would like to call my program as follows:</p>
  
  <pre><code>curl http://www.example.com/video.wmv | vpipe processed.wmv
  </code></pre>
  
  <p>Unfortunately doesn't work, because there is no such an option for popen3 as :stdin_data. I also tried Open3.capture3 which can take this argument, but then I got en error message from curl: "Failed writing body".</p>