开发者

Rails not responding to ffmpeg commands

开发者 https://www.devze.com 2023-03-25 12:44 出处:网络
I am trying to run this command here: f = open(\"|ffmpeg -i /Users/joaoh82/Desktop/teste.MP4\") result = f.read()

I am trying to run this command here:

f = open("|ffmpeg -i /Users/joaoh82/Desktop/teste.MP4")
result = f.read()

But I am not getting any response...

But when I try this command in the terminal it works great:

开发者_Go百科ffmpeg -i /Users/joaoh82/Desktop/teste.MP4

But now on rails code. Funny thing is that when I try the same thing with some else like an echo $PATH it works great! Like:

f = open("|echo $PATH")
result = f.read()

Any ideas!?


ffmpeg -i prints to stderr, which won't be captured by your pipe. You could redirect stderr to stdout:

result = `ffmpeg -i /Users/joaoh82/Desktop/teste.MP4 2>&1`


You probably need to specify the full path to ffmpeg. It might be working in your shell because ffmpeg is in your PATH.

Basically in your shell, type which ffmpeg. Use that full path in your open() call.

0

精彩评论

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