[MPlayer-users] change_rectangle in slave mode doesn't do anything

Rolf Ernst rolf.ernst at silverlightning.org
Wed Apr 13 17:21:33 CEST 2011


On Wed, Apr 13, 2011 at 9:54 AM, Steve Ricketts <velocedge at hotmail.com>wrote:

> > Well, the whole idea of slave mode is to run it
> from a piece of code instead
> > of the command line. I do not believe the
> change_rectangle is available as
> > an interactive command.
>
> Ok, here's what I wrote.  It starts the video ok, but after the sleep(10)
> rather
> than resizing the video, it starts a new video playing at the beginning and
> I
> end up with two of the same size.
>
> static FILE *videoPipe;
>
> void startVideoPlayer (char *videoType, char *videoFile, char *videoOffset)
> {
>        char str[512];
>
>        if(CMD_EQUAL (videoType, "MPLAYER"))
>        {
>                strcpy(str, "mplayer -slave '");
>                strcat(str, videoFile);
>                strcat(str, "'");
>                DEBUG(LOGD"Run video: %s", str);
>                videoPipe = popen(str, "w");
>                sleep(10);
>                fputs("change_rectangle 0 -100\n", videoPipe);
>                fputs("change_rectangle 1 100\n", videoPipe);
>                fflush(videoPipe);
>         }
> }
>
> I should preface that with the caveat that I do this in Java but I don't
think this should matter in this case. Since I don't see the rest of your
code - are you sure you do not reissue the popen() somewhere so you wind up
with two processes?

Secondly, although this may now play into your particular problem- you
should ensure that you keep reading stderr and stdout. I create separate
threads for that. Otherwise mplayer may eventually wait until you read
those.

Finally - change_rectangle does not *resize* the video. It draws a rectangle
(a white line) on top of the video. By changing its dimensions you can (as
my code does) determine how you later on want to crop it. It does not do any
cropping or resizing on it's own. It is sort-of a very handy 'preview'
feature. All the while mplayer writes all sorts of interesting things to
stdout which you should read out.

Anyhow, so much I can say from here. I could send you my code but it is part
of a rather large class...


More information about the MPlayer-users mailing list