title: Get ffmpeg info from Pipe (stdout)
body: <p>I want to call ffmpeg to get the duration of a video file. When using the command in OSX Terminal everything works fine:</p>
  <pre><code>ffmpeg -i MyVideo.MOV 2&gt;&amp;1 | grep &quot;Duration&quot;
  </code></pre>
  <p>I get this:</p>
  <pre><code>  Duration: 00:01:23.53, start: 0.000000, bitrate: 39822 kb/s
  </code></pre>
  <p>It is perfect for me. But now I tried this call from within my code:</p>
  <pre><code>func shell(launchPath: String, arguments: [String]) -&gt; String
  {
      let task = Process()
      task.launchPath = launchPath
      task.arguments  = arguments
  
      let pipe = Pipe()
      task.standardOutput = pipe
      
      do {
          try task.run()
          // task.launch() till 10.12, but now catchable!
      } catch let error as NSError {
          print(error.localizedDescription)
          return &quot;&quot;
      }
      
      let data = pipe.fileHandleForReading.readDataToEndOfFile()
      let output: String = NSString(data: data, encoding: String.Encoding.utf8.rawValue)! as String
  
      return output
  }
  </code></pre>
  <p>This code works fine for all other external commands. But here I get error:</p>
  <pre><code>[NULL @ 0x107808800] Unable to find a suitable output format for '2&gt;&amp;1'
  2&gt;&amp;1: Invalid argument
  </code></pre>
  <p>I defined the arguments for ffmpeg like this:</p>
  <pre><code>let arguments = [&quot;-i&quot;, video.path, &quot;2&gt;&amp;1&quot;, &quot;|&quot;, &quot;grep \&quot;Duration\&quot;&quot; ]
  </code></pre>
  <p>Even if I put them all in one argument as a larger string, it doesn't work. Using &quot;pipe:1&quot; instead of &quot;2&gt;&amp;1&quot; and rest of arguments results also in an error.</p>
  <p>Any idea, how I get it to work?</p>