[MPlayer-users] Reading MPlayer in slave mode with C using libevent
Reimar.Doeffinger at gmx.de
Sun Apr 17 20:45:17 CEST 2011
On Sun, Apr 17, 2011 at 06:08:51PM +0000, Steve Ricketts wrote:
> Reimar Döffinger <Reimar.Doeffinger <at> gmx.de> writes:
> > On Sun, Apr 17, 2011 at 05:21:45PM +0000, Steve Ricketts wrote:
> > > videoPipe = popen(str, "w");
> > MPlayer writes some things to stderr, and popen will only capture stdout.
> > Or rather would, since you open for writing it will actually
> > capture neither stdout nor stderr.
> Makes sense of course... but then what options to I have to read the output from
> mplayer? I'm too new to know what I'm really talking about but could I do
> something like having mplayer direct it's output to a socket and I put the
> callback on that socket?
Since popen takes any shell command you can add redirects as you like.
Or you can manually set things up by using pipe, fork, dup2 and exec.
I'm sure there should be enough tutorials around.
However if this is the first time you're doing this kind of thing both
approaches will probably result in code with quite a few security issues.
If this matters you might look for code that has more convenient helper
functions for this. Python certainly has popen variants for this,
Qt almost certainly has, I am sure there must be some pure C library
that offers such things as well, but I don't know any out of my head.
More information about the MPlayer-users