Redirect shell output for ruby script

I have simple ruby script :

 #! /usr/bin/env ruby
 require 'fileutils'

 FileUtils.rm "output.mkv" if File.exists?("outp    ut.mkv")
 pid = Process.spawn("ffmpeg -i wrong_file.mp4 -c:v libx264 -preset veryslow -qp 0 output.mkv", STDOUT => "output.txt", STDERR => "error.txt")

 puts "pid : #{pid}"

But, STDOUT and STDERR outputs into error.txt, why ?

It looks, that ffmpeg have another exit codes ?(in usual case 0 for stdout, and 1 for stdin)

Note: I don’t want to use native shell redirect like ‘> output.txt 2> error.txt’ because i want to get pid of ffmpeg process, not shell process and kill it in future.

Source: ruby

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.