开发者

ruby wont read output of ffmpeg

开发者 https://www.devze.com 2023-02-03 19:45 出处:网络
running a = 开发者_JS百科`ffmpeg -i video.mp4` does not seem to give the output of the command into a... Why is that? how do override it?Quick answer:

running

a = 开发者_JS百科`ffmpeg -i video.mp4`

does not seem to give the output of the command into a... Why is that? how do override it?


Quick answer:

a = `ffmpeg -i video.mp4 2>&1`

Detailed answer:

When I ran ffmpeg -i blah.avi on a handy file, I noticed that none of its output when out to standard out; instead, all the output when to standard error. You can check yourself at the shell by running:

ffmpeg -i video.mp4 > /tmp/standard_out 2> /tmp/standard_error

Then look at both /tmp/standard_out and /tmp/standard_error. You'll see which one is which quickly. You can quickly 'fix' this by using ffmpeg -i video.mp4 2>&1 in your script, which will ask the shell to redirect stderr along with stdout. You won't be able to tell the difference between stderr and stdout, but you can get the output you 'see' easily enough.

You'll have to use popen3 if you want to keep stdout and stderr separate.

0

精彩评论

暂无评论...
验证码 换一张
取 消