[erlang-questions] open_port vs. unix pipes

Rapsey rapsey@REDACTED
Sat Oct 25 12:05:58 CEST 2008

What is the difference for the program that communicates using stdin and
stdout, if it is opened using open_port from within erlang or with unix
I'm trying to use open_port with ffmpeg, this works just fine for instance:

cat blabla.mp3 | /opt/local/bin/ffmpeg -f mp3 -i - -acodec libfaac -f flv -
> dan.flv

But if I use open_port:
{ok, Bin} = file:read_file("blabla.mp3"),
Port = open_port({spawn, "/opt/local/bin/ffmpeg -f mp3 -i - -acodec libfaac
-f flv -"}, [binary, use_stdio, stream]),
<<Data:128000/binary, Remain/binary>> = Bin,
Port ! {Port {command, Data}}

ffmpeg call will fail with:
pipe:: Error while opening file

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081025/0f560e2f/attachment.htm>

More information about the erlang-questions mailing list